ASP.NET WebMethods – Request Information

When handling a Web Service it’s easy to focus on the parameters passed in to the web method, but there is a lot of additional information that comes along with the overall web platform.  You can access the various Uri information at System.Web.HttpContext.Current.Request.Url.

User Information including the Host Address and Name

UserHostAddress: “192.168.0.50”
UserHostName: “192.168.0.50”

The URL Infomation

  •     AbsoluteUri: “http://192.168.0.73/snapRETAIL/Security/snapRETAIL.Security.WS.asmx/LogonWithSiteNoHashNew” – The full path of the URL.
  •     OriginalString: “http://192.168.0.73:80/snapRETAIL/Security/snapRETAIL.Security.WS.asmx/LogonWithSiteNoHashNew” – The Uri as entered on the client.

 Server Host Information

  • Host: “192.168.0.73”
  • DnsSafeHost: “192.168.0.73”
  • Port: 80
  • Scheme: “http”

Note: DnsSafeHost is the one that can be used to do a call that is processed by DNS, it is sanitized to eliminate extended characters that don’t work with DNS.  Host is the original value which can included these characters.  Also see SO: Host vs DnsSafeHost.

The referring page.

  • UrlReferrer: {http://192.168.0.73/snapRETAIL/HHT/Home/Logon}

Leave a Reply

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