Site icon Ryadel

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.

 

Exit mobile version