Instead of getting a HTTP 404 response, I\'d like to have a generic 404 Not Found page (HTTP 200). I know you can set that up in MVC 5 with
If anyone is looking to create custom 404 pages with HTML, you can do this:
Startup.cs
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseStatusCodePagesWithReExecute("/errors/{0}");
}
}
project.json
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
// ....
}
ErrorsController.cs
public class ErrorsController : Controller
{
// ....
[Route("/Error/{statusCode}")]
public IActionResult ErrorRoute(string statusCode)
{
if (statusCode == "500" | statusCode == "404")
{
return View(statusCode);
}
return View("~/Views/Errors/Default.cshtml");
}
}
All that's left after this is to create a 404.cshtml, 500.cshtml, and Default.cshtml in your Errors view folder and customize the HTML to your liking.