I'm trying this solution to use URL among my razor view.
but unfortunately I have this compiler error:
the name 'Request' does not exist in the current context
I tried this solution too, but still HttpContext.Current.Request
is unknown for compiler!
SOLUTION:
I used @Context.Request.Path
and the issue solved. thanks to Xinran Shen
In your razor view, You use:
@Context.Request.Path
to get the current request path directly. If you wanna get the whole request path(include host), you can use
@using Microsoft.AspNetCore.Http.Extensions
@Context.Request.GetEncodedUrl()
Hope it can solve your issue.