Search This Blog

Tuesday, 24 July 2012

Get the domain name from SharePoint 2010 Url

Scenario : I have to get the domain name alone from the SharePoint 2010 Url,

Ex: http://trig:1986  ------------> Url
      here the domain name in trig. Now i need to get this in my code behind.

I found the solution for this. Refer the below code snippet


            Uri urlnew = new Uri("http://triad102:1990");
            string split = urlnew.Scheme + Uri.SchemeDelimiter + urlnew.Host + ":" + urlnew.Port;
            Console.WriteLine("Full Url :: http://triad102:1190");
            Console.WriteLine("Scheme :: " + urlnew.Scheme);
            Console.WriteLine("SchemeDelimiter :: " + Uri.SchemeDelimiter);
            Console.WriteLine("Host :: " + urlnew.Host);
            Console.WriteLine("Port :: " + urlnew.Port);

Result :









No comments:

Post a Comment