How to get current URL? I try that:
Program.cs
var location = new Uri($"{Request.Scheme}://{Request.Host}{Request.Path}{Request.QueryString}");
or
public string BuildAbsolute(PathString path, QueryString query = default(QueryString), FragmentString fragment = default(FragmentString))
{
var rq = HttpContent.Request;
return Microsoft.AspNetCore.Http.Extensions.UriHelper.BuildAbsolute(rq.Scheme, rq.Host, rq.PathBase, path, query, fragment);
}
Visual Studio does not find "Request"
The only thing I need is to take the current URL and Host / Path
You can run your functions inside Startup.cs inside Configure using middleware. You can do
app.Use(async (context,next)=>{
//Do what you want with context,which is HttpContext
await next.Invoke();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With