可能重复:
从子域获取域
我有一个查询,我正在从 URI 中获取主机名。
Eg. if i have http://www.google.com/abc/abcd/ade/a.htm
then the url is "www.google.com"
var uri = new Uri("http://www.google.com/abc/abcd/ade/a.htm");
uri.Host // i get www.google.com
But when i try it with Subdomain i want to exclude the Subdomain from the url
var uri = new Uri("http://mail.google.com/abc/abcd/ade/a.htm");
uri.Host // i get mail.google.com
I want only google.com