To get the Host name and IP address from your ASP.NET application, we have option is .NET. Using the using System.Net; namespace you have access to the classes which can expose the Host name and IP address.
The sample code to explain the solution. Paste the same code in the page load event of the ASP.NET page.
using System.Net;
//Get the Host name
string strHostName = string.Empty;
strHostName = Dns.GetHostName();
// Then using host name, get the IP address list..
IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
//Get the IP address
IPAddress [] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
Response.Write("IP Address {0}: {1} " + i + addr[i].ToString() + ", HostName: " + strHostName);
}
Subscribe to:
Post Comments (Atom)
ASP.NET MVC - Sport Facility Booking system
The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...
-
"The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, II...
-
Excellent outcome by some of the Microsoft Technology community influencers. CAML.NET IntelliSense for SharePoint To build a SharePoint feat...
-
The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...
2 comments:
Dear,
Thank you very much, i was stuck with this problem, i have found it and it is working fine,
thanks
Saif ur rehman saifi
Islamabad, Pakistan
Dear, Thanks For This easy and useful code, but this code to get the host info. but how to get the Client ip and computer name to use it in MaintenanceRequest.
Thanks
Post a Comment