Get raw URL from Microsoft.AspNet.Http.HttpRequest

后端 未结 8 807
醉酒成梦
醉酒成梦 2020-12-02 21:40

The HttpRequest class in Asp.Net 5 (vNext) contains (amongst other things) parsed details about the URL for the request, such as Scheme, Host

8条回答
  •  醉话见心
    2020-12-02 22:18

    In .NET Core razor:

    @using Microsoft.AspNetCore.Http.Extensions
    @Context.Request.GetEncodedUrl() //Use for any purpose (encoded for safe automation)
    

    You can also use instead of the second line:

    @Context.Request.GetDisplayUrl() //Use to display the URL only
    

提交回复
热议问题