62,268
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 返回当前网站的根路径,如:http://www.mydaigo.com
/// </summary>
/// <returns>返回当前网站的根路径</returns>
public static string GetWebRootPath()
{
string path = "", port = "", urlHost = "";
path = HttpContext.Current.Request.ApplicationPath;
port = HttpContext.Current.Request.Url.Port.ToString();
urlHost = HttpContext.Current.Request.Url.Host;
if (path == "/")
path = "";
if (port == "80")
{ port = ""; }
else
{ port = ":" + port; }
return "http://" + urlHost + port + path;
}