get current page from url

前端 未结 6 1828
无人及你
无人及你 2020-12-30 19:45

I want to write a c# method to retrieve the current page. eg Default6.aspx I know I can do the following:

string url = HttpContext.Current.Request.Url.Absolu         


        
6条回答
  •  遥遥无期
    2020-12-30 20:25

    A simple function like below will help :

    public string GetCurrentPageName() 
    { 
        string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath; 
        System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath); 
        string sRet = oInfo.Name; 
        return sRet; 
    } 
    

提交回复
热议问题