获得当前网页的页面名称
2015-12-05 09:26:20 访问(1358) 赞(0) 踩(0)
/// <summary>
/// 获得当前网页的页面名称 list.aspx
/// </summary>
/// <returns></returns>
public static string GetCurPageName()
{
HttpContext hc = HttpContext.Current;
if (hc == null)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "HttpContext hc = HttpContext.Current为null。"
);
}
// 虚拟目录加完整参数页面地址 //
// /SlowXWebSite/Test/WebCommon/Default.aspx?id=default.aspx&web=%cb%aa%d2%b6&dt=D%3a%5ccanoe%5cs.aspx&p=fdf%5cf%2ffds.fdsf%3ffdf //
string strPathAndQuery = hc.Request.Url.PathAndQuery;
if (strPathAndQuery == null || strPathAndQuery.Length == 0)
return "";
int idx = strPathAndQuery.LastIndexOf("?");
if (idx != -1)
strPathAndQuery = strPathAndQuery.Substring(0, idx);
idx = strPathAndQuery.LastIndexOf("/");
if (idx != -1)
strPathAndQuery = strPathAndQuery.Substring(idx + 1);
return strPathAndQuery;
}
标签:
获得当前网页的页面名称 


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