获取当前页面的名称,和 请求 前一页面 的 名称

 /// <summary> ///获取当前页面的名称 /// </summary>      

 /// <returns></returns>      

 public static string GetPageName()        {          

 return HttpContext.Current.Request.ServerVariables["PATH_TRANSLATED"].ToString().Replace(HttpContext.Current.Server.MapPath(""), "").Substring(1);    

   }

 /// <summary> ///获取前一请求页面的名称 /// </summary>      

 /// <returns></returns>      

 public static string GetPageName()        {          

   return  HttpContext.Current.Request.ServerVariables["HTTP_REFERER"].ToString().Substring(                                              HttpContext.Current.Request.ServerVariables["HTTP_REFERER"].ToString().LastIndexOf('/')).Trim('/');   

   }

posted @ 2011-04-20 09:44  youngff  阅读(1286)  评论(0)    收藏  举报