You can get all the response codes, it's up to you whether you need to display a different page for each code.
For example, use UseStatusCodePagesWithReExecute
middleware:
Program.cs:
app.UseStatusCodePagesWithReExecute("/Home/Error", "?statusCode={0}");
Controller:
public IActionResult Error(int? statusCode = null)
{
if (statusCode.HasValue)
{
ViewData["Message"] = statusCode;
return View("ErrorPage");
}
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
[Route("ErrorPage")]
public IActionResult ErrorPage()
{
return View();
}
In ErrorPage.cshtml, you can use ViewData["Message"]
to get the response code and display different content for it.
Or you can create a view for each response code like this.
For more details, you can refer to this document.