You can use Request
object or Uri
object to get host of url.
Using Request.Url
string host = Request.Url.Host;
Using Uri
Uri myUri = new Uri("http://www.contoso.com:8080/");
string host = myUri.Host; // host is "www.contoso.com"
More Related Contents:
- How to check whether a string is a valid HTTP URL?
- Get file name from URI string in C#
- C# how to check if a string contains 3 times the same letters in a row [closed]
- How to trim after 1 letter from space C#? [closed]
- How would you count occurrences of a string (actually a char) within a string?
- How to convert UTF-8 byte[] to string
- How do I parse a string with a decimal point to a double?
- How to post JSON to a server using C#?
- Splitting a string into chunks of a certain size
- Color different parts of a RichTextBox string
- How do I replace multiple spaces with a single space in C#?
- Convert int to string?
- Difference between string and StringBuilder in C#
- How to parse a string into a nullable int
- Compare version numbers without using split function
- How do I split a string by strings and include the delimiters using .NET?
- How to download image from URL
- “Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions” error
- Write bytes to file
- Pick Random String From Array
- Java equivalent of C#’s verbatim strings with @
- How to create LINQ Query from string?
- How to convert string to integer in C#
- C# HttpWebRequest of type “application/x-www-form-urlencoded” – how to send ‘&’ character in content body?
- Converting a byte to a binary string in c#
- How to make an HTTP get request with parameters
- HttpWebRequests sends parameterless URI in Authorization header
- How to change the port number for Asp.Net core app?
- Parsing formatted string
- Parsing through Arabic / RTL text from left to right