I noticed that when you create a default asp.net core project in visual studio, there is an Error action that looks like this:
public IActionResult Error()
{
ViewData["RequestId"] = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
return View();
}
The error page shows that RequestId properly, however, I don't know how to check the details of that error if my user sends me a screenshot of that error. Where is this stored?
ExceptionHandlerMiddleware stores the exception in HttpContext as an ExceptionHandlerFeature.
So in the Error Action you can get the error message by doing something like this,
public IActionResult Error()
{
var ehf = HttpContext.Features.Get<IExceptionHandlerFeature>();
ViewData["ErrorMessage"] = ehf.Error.Message;
return View();
}
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