在 ASP.NET Core 中,Request.GetDisplayUrl() 会包含查询字符串,比如请求下面的 url
https://www.cnblogs.com/dudu/tag/k8s/default.html?page=2
GetDisplayUrl 会返回和上面一模一样的的 url,而实际需要的是不带 query string 的 url
https://www.cnblogs.com/dudu/tag/k8s/default.html
请问如何实现?
通过 Uri.GetLeftPart 方法解决了
var url = new Uri(Request.GetDisplayUrl()).GetLeftPart(UriPartial.Path);