I followed the doc on implementing custom error pages, and I can only get the 404 page to work via the appsettings.json “Error404Collection” setting, but not a 404 and 500 error message via the suggested controller implementation. I can debug and see it go to my nodes at /error/404 and /error/500, but it doesn’t display the content page created for them, but instead shows the default browser error.
This is what I have for the controller (which does work when stepping through):
using Microsoft.AspNetCore.Mvc;
namespace USD.Site.Controllers;
public class ErrorController : Controller
{
[Route(“Error”)]
public IActionResult Index()
{
if(Response.StatusCode == StatusCodes.Status500InternalServerError)
{
return Redirect(“/error/500”);
}
else if(Response.StatusCode != StatusCodes.Status200OK)
{
return Redirect(“/error/404”);
}
return Redirect(“/”);
}
}
For now I’ll use the appSettings.json setting and just always use the 404 content node, but I wanted to setup the 500 to display if applicable too.
