ASP.NET C# Helper Class to execute a ICMPv4 PING to any remote host using hostname or IP Address

Classe ASP.NET C# per il controllo e il calcolo formale del Codice Fiscale

Today I want to share this small, yet useful C# helper class that I still use when I need to retrieve, check or validate one or more IP Addresses registered on the Web Server. You can use it for a number of tasks/scenarios, including:

  • Retrieve the first available IP Address of the Web Server machine hosting the Web Application.
  • Retrieve a list of all the IPV4 and IPV6 Addresses registered on the Web Server machine hosting the Web Application.
  • Check if a given IP Address is one of the IP Addresses registered on the Web Server.

The helper class was made some years ago, yet it can still be used on any ASP.NET project, including ASP.NET Forms, ASPX pages, ASP.NET MVC, ASP.NET Web API, ASP.NET WCF with any other framework versions & builds, up to the most recent ASP.NET Core.

Here it is: enjoy!

In case you also need to retrieve IP Address(es) of the Web Server machine hosting the Web Application and/or check if a given IP Address is registered on the Web Server or not, you can integrate within this class the GetIPAddress, GetIPAddresses and HasIPAddress methods described in this other post.

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

0 Comments on “ASP.NET C# Helper Class to execute a ICMPv4 PING to any remote host using hostname or IP Address”

  1. Pingback: C# Class to get Web Server IP Address and other network-related methods

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.