Hàm Get sudomain in trong URL - The URL to get the sub domain from


public static string GetSubDomain(Uri url)
{      
   if (url.HostNameType == UriHostNameType.Dns)
   {
         var host = url.Host;
         if (host.Split('.').Length > 2)
         {
               var lastIndex = host.LastIndexOf(".");
               var index = host.LastIndexOf(".", lastIndex - 1);
               return host.Substring(0, index);
          }
    }

    return null;
}
Hàm Get sudomain in trong URL - The URL to get the sub domain from

Share To:

laptrinhvien

Post A Comment:

0 comments so far,add yours