页面当前目录相对网站的地址 - GetCurDirWebSitePath
2017-01-25 17:50:29 访问(1597) 赞(0) 踩(0)
/// <summary>
/// 页面当前目录相对网站的地址
/// /WebForms/WebPages/code/dotnet/HttpContextInfo/Info
/// </summary>
/// <returns></returns>
public string GetCurDirWebSitePath()
{
HttpContext hc = HttpContext.Current;
if (hc == null)
return "";
string str = hc.Request.Url.PathAndQuery;
int idx = str.LastIndexOf('/');
if (idx == -1)
return "";
str = str.Substring(0, idx);
if (hc.Request.ApplicationPath == "/")
return str;
return str.Substring(hc.Request.ApplicationPath.Length);
}
标签:
页面当前目录相对网站的地址 - GetCurDirWebSitePath 


上一条:
下一条:
相关评论
发表评论