This. Request. url. getleftpart (uripartial. Authority)
You can get a http://www.baidu.com, no matter what the request is. In additionUripartial enumerated value. You can obtain strings such as path and querystring.
The following content source:Http://www.xueit.com/html/2009-03/21_932_00.html
---------------------------------------------------------------------
Obtain the URL of the website root directorySource code
Public static string getrooturi ()
{< BR style = "padding: 0px; margin: 0px;"> string apppath = "";
httpcontext httpcurrent = httpcontext. current;
httprequest req;
If (httpcurrent! = NULL)
{< BR style = "padding: 0px; margin: 0px;"> Req = httpcurrent. request;
String urlauthority = Req. url. getleftpart (uripartial. authority );
If (req. applicationpath = NULL | Req. applicationpath = "/")
// Directly install on the Web Site
Apppath = urlauthority;
Else
// Install it in a virtual subdirectory
Apppath = urlauthority + Req. applicationpath;
}
Return apppath;
}