Is there a simple way in .NET to quickly get the current protocol, host, and port? For example, if I'm on the following URL:
http://www.mywebsite.com:80/pages/page1.aspx
I need to return:
http://www.mywebsite.com:80
I know I can use Request.Url.AbsoluteUri
to get the complete URL, and I know I can use Request.Url.Authority
to get the host and port, but I'm not sure of the best way to get the protocol without parsing out the URL string.
Any suggestions?
Well if you are doing this in Asp.Net or have access to HttpContext.Current.Request I'd say these are easier and more general ways of getting them:
I hope this helps. :)