My present configuration:
public void ConfigureDevelopment(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
//app.UseDeveloperExceptionPage();
//app.UseDatabaseErrorPage();
app.UseStatusCodePagesWithRedirects("/error/{0}");
app.UseExceptionHandler();
Configure(app);
}
I have this controller that is supposed to be executed when the server register any exceptions. When I execute "error/test" I'm redirected to "error/500" as expected. If I manually execute "error/exception", I get the server 500 native error, not mine.
public class ErrorController : Controller
{
[Route("error/404")]
public ActionResult Error404()
{
return View("404");
}
[Route("error/500")]
public ActionResult Error500()
{
return View("500");
}
[Route("error/test")]
public ActionResult Test()
{
return new StatusCodeResult(500);
}
[Route("error/exception")]
public ActionResult Exception()
{
throw new Exception("Should redirect to error/500");
return Content("nope");
}
}
Any idea how to redirect "error/exception" to "error/500" when exception is thrown in actions?
Thank you.