How to get Current Page's Url in asp.net using code behind technique?

后端 未结 4 688
天命终不由人
天命终不由人 2020-12-31 21:08

I want to get Url of the page like abc.aspx. how can i get this using code behind technique. Any idea.?

4条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 22:08

    Full Details, you can later use string Operations for advanced manipulation:

    string url = HttpContext.Current.Request.Url.AbsoluteUri;
    // http://localhost:1302/TESTERS/Default6.aspx
    
    string path = HttpContext.Current.Request.Url.AbsolutePath;
    // /TESTERS/Default6.aspx
    
    string host = HttpContext.Current.Request.Url.Host;
    // localhost
    

    How to get the URL of the current page in C#

提交回复
热议问题