.NET – Get protocol, host, and port
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:
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:
I want to write a little helper method which returns the base URL of the site. This is what I came up with:
net 4 and c#.
im using code as below to check for the URL validation:
I’m writing a method which, let’s say, given 1 and hello should return http://something.com/?something=1&hello=en.
If I create a Uri class instance from string that has trailing full stops – ‘.’, they are truncated from the resulting Uri object.