I need to get the domain name without the top level domain suffix of a given url.
e.g
Url :
www.google.com
then output=google
Url :
http://www.google.co.uk/path1/path2
then output=google
Url :
http://google.co.uk/path1/path2
then output=google
Url :
http://google.com
then output=google
Url :
http://google.co.in
then output=google
Url :
http://mail.google.co.in
then output=google
For that i try this code
var uri = new Uri("http://www.google.co.uk/path1/path2");
var sURL = uri.Host;
string[] aa = sURL.Split('.');
MessageBox.Show(aa[1]);
But every time i can't get correct output(specialty url without www
). after that i search no google and try to solve it but it's help less. i also see the question on stackoverflow but it can't work for me.