简体   繁体   English

如何从 url 获取当前页面,不包括查询字符串参数

[英]how to get current page from url excluding query string parameters

How to get current page URL excluding query string parameters.如何获取不包括查询字符串参数的当前页面 URL。 My URL is like this https://mywebsite.com/myproject/detailspage?id=2812我的网址是这样的https://mywebsite.com/myproject/detailspage?id=2812

I want to get only https://mywebsite.com/myproject/detailspage .我只想获取https://mywebsite.com/myproject/detailspage

I tried this but not helped.我试过这个,但没有帮助。

string path = HttpContext.Current.Request.Url.AbsolutePath;
string url = HttpContext.Current.Request.Url.AbsoluteUri;

Please any suggestions.请任何建议。

Request.Url.GetLeftPart(UriPartial.Path)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM