Middleware are heart of an ASP.NET Core application. You can think of middleware as small connectors which makes a pipeline to accept requests and send responses. Anything which your ASP.NET core application does is performed by middleware. Middleware are small application components that can be incorporated into an HTTP request pipeline like HttpHandlers and HttpModules. But middleware are different from HttpModules. In this post, we take a look at various ASP.NET Core Diagnostics middleware examples which are used for error logging and handling, exception handling and runtime environment information.
Earlier I posted quick summary of what’s changed in ASP.NET Core and one of the biggest change is Introduction of middleware. If you are coming from ASP.NET background then you should be aware about HTTPHandlers and HTTPModules. Middleware are replacement of these things. It’s a new and cleaner approach to play with HTTP pipeline. Read my post How ASP.NET Core 1.0 Middleware is different from HttpModule.
Along with built-in middleware, there are 2 options to define inline middleware using
app.Run extension methods. And if you are currently working and playing with ASP.NET Core 1.0 then you may find examples of
configure() method of Startup.cs class. Both of them are used for same purpose but they are different. How?
Prior versions of ASP.NET Core 1.0, have custom errors for error handling. With ASP.NET Core 1.0 and MVC, you can do the error handling via Middlwares. HTTP 404 is a very common error which comes when server can’t find the requested resource. In this post, we will see different ways to handle HTTP 404 error in ASP.NET Core 1.0 and MVC.
Earlier I posted about changes in ASP.NET Core 1.0 and one of the biggest change is in HTTP pipeline. We as ASP.NET developers are quite familiar with
HttpModules but with this new version of ASP.NET, they are gone. They are replaced with a new better, cleaner and easy to implement approach called “Middleware“. You can think of Middleware is a combination of
HttpModule. In this post, find out how ASP.NET Core 1.0 Middleware is different from HttpModule.