I'm using ASP.NET CORE 3.1 project in the new release of VS Community 2019
In the Configure(IApplicationBuilder app, IWebHostEnvironment env) in my startup.cs file I have the line:
app.UseExceptionHandler("/Home/Error");
So when I throw an error somewhere in a Controller e.g.
throw new Exception("User Not Found!");
This then bounces to this default IActionResult in the HomeController:
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
I was hoping to pass something (either the Exception or its message) to the IActionResult Error() but I'm not sure that's possible.
So then I thought
is the Exception thrown in the BaseController accessible from the Error IActionResult at all? Possibly by using the HttpContext or the Activity ?
I can't seem to find anything using the intellisense, not sure I'm approaching it the right way and probably need to setup a whole new error handling system.