You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 8, 2018. It is now read-only.
I'm trying to log the request URI when an exception is thrown. Logging is too abstracted out to do it so I thought that IHttpRequestFeature was my trick. Here's what I'm trying, please let me know if I'm way off the right track:
First I'm using an exception page:
app.UseExceptionPage("/Exception");
This logs the exception, but just the bare exception, no state of the request.
So, inside the Action for /Exception, I'm doing this:
[HttpGet("Exception")]
public IActionResult Exception()
{
var exception = HttpContext.Features.Get<IExceptionHandlerFeature>();
var request = HttpContext.Features.Get<IHttpRequestFeature>();
if (exception != null && request != null)
{
var originalPath = request.Path;
// I could cast the request object to a Frame to get at the information, but that feels dirty
// Manually logging the information
}
return View();
}
When a 403 is encountered I'd like to get the RequestURI to log what URL user attempted. Shouldn't ReuestURI be on the IHTTPRequestFeature in that case as well? I see the original request was for it to be on IHttpRequestFeature. I still think it should be there. I use app.UseStatusCodePagesWithReExecute.
From @shawnwildermuth on May 12, 2016 19:42
I'm trying to log the request URI when an exception is thrown. Logging is too abstracted out to do it so I thought that IHttpRequestFeature was my trick. Here's what I'm trying, please let me know if I'm way off the right track:
First I'm using an exception page:
This logs the exception, but just the bare exception, no state of the request.
So, inside the Action for /Exception, I'm doing this:
Copied from original issue: aspnet/HttpAbstractions#630
The text was updated successfully, but these errors were encountered: