What is the ASP.NET Core MVC equivalent to Request.RequestURI?

后端 未结 3 1467
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 14:11

I found a blog post that shows how to \"shim\" familiar things like HttpResponseMessage back into ASP.NET Core MVC, but I want to know what\'s the new native way to do the s

3条回答
  •  醉酒成梦
    2020-12-14 15:06

    Personally, I use :

    new Uri(request.GetDisplayUrl())
    
    • GetDisplayUrl fully un-escaped form (except for the QueryString)
    • GetEncodedUrl - fully escaped form suitable for use in HTTP headers

    These are extension method from the following namespace : Microsoft.AspNetCore.Http.Extensions

提交回复
热议问题