Get raw URL from Microsoft.AspNetCore.Http.HttpRequest

Add the Nuget package / using:

using Microsoft.AspNetCore.Http.Extensions; 

(In ASP.NET Core RC1 this was in Microsoft.AspNet.Http.Extensions)

then you can get the full http request url by executing:

var url = httpContext.Request.GetEncodedUrl();

or

var url = httpContext.Request.GetDisplayUrl();

depending on the purposes.

Leave a Comment