这个函数可以得到http://localhost/

private string GetBaseURL()//这个函数可以得到http://localhost/
{
if (HttpContext.Current.Request.ApplicationPath == "/")
{
return @"http://" + HttpContext.Current.Request.Url.Host;
}
else
{
return @"http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
}
}

你可能感兴趣的:(这个函数可以得到http://localhost/)