Live Chat Icon For mobile
Live Chat Icon

How to get the hostname or IP address of the server?

Platform: ASP.NET| Category: Basic

You can use either of these:

  • HttpContext.Current.Server.MachineName
  • HttpContext.Current.Request.ServerVariables[‘LOCAL_ADDR’]

The first one should return the name of the machine, the second returns the local ip address.

Note that name of the machine could be different than host, since your site could be using host headers

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.