Friday, February 10, 2012

Get url of the current page asp.net


       Get url of the current page asp.net 

 string url = HttpContext.Current.Request.Url.AbsoluteUri;
        // http://localhost:1302/TESTERS/Default6.aspx
        string path = HttpContext.Current.Request.Url.AbsolutePath;
        // /TESTERS/Default6.aspx
        string host = HttpContext.Current.Request.Url.Host;
        // test.aspx      
        string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
        System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
        string sRet = oInfo.Name;

No comments:

Post a Comment