Etiket: Get Current Site URL

How Can I Get Current Site Url in Sharepoint (Programmatically)

Nisan 7th, 2009
       private string GetServerUrl()
        {
            string strContextURL = HttpContext.Current.Request.Url.ToString(); //Full Url of the current site
            int i = strContextURL.LastIndexOf("//") + 2;
            string strProtocol = strContextURL.Substring(0, i); //to find protocol
            string strServer = strContextURL.Substring(i); //to find server
            string strBaseUrl = strProtocol + strServer.Substring(0, strServer.IndexOf("/"));
            return strBaseUrl;
        }

Tags: , , ,
Posted in Sharepoint, Yazılım | No Comments »