c# .net

Get you domain name from URL

Get you domain name from URL, someone asked me to explain?

It can be achieved by two methods, getting the domain hosted name using URL request Request.Url.Host and another by Uri. 

var url = "http://www.aljazeera.com/news/2016/07/dallas-police-suspect-affiliated-group-160708132417429.html";
            Uri myUri = new Uri(url);
            string host = myUri.Host;

 Output:

 

www.aljazeera.com

Post your comments / questions