Using Custom Middleware to Record and Fix 404s in ASPNET Core Apps

Date Published: 14 June 2016

Using Custom Middleware to Record and Fix 404s in ASPNET Core Apps

My most recent article in MSDN Magazine is now available online:

ASP.NET – Use Custom Middle Middleware to Detect and Fix 404s in ASP.NET Core Apps

The article was written in the ASP.NET 5 RC1 timeframe, but the sample code has been updated to RC2 and is available on GitHub.

From the introduction:

If you’ve ever lost something at a school or an amusement park, you may have had the good fortune of getting it back by checking the location’s Lost and Found. In Web applications, users frequently make requests for paths that aren’t handled by the server, resulting in 404 Not Found response codes (and occasionally humorous pages explaining the problem to the user). Typically, it’s up to the user to find what they’re looking for on their own, either through repeated guesses or perhaps using a search engine. However, with a bit of middleware, you can add a “lost and found” to your ASP.NET Core app that will help users find the resources they’re looking for.

And here’s a screenshot of what the article builds:

If you have questions or comments, you can add them here or in the article’s MSDN forum.

Steve Smith

About Ardalis

Software Architect

Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.