ASP.NET MVC 5: OWIN/Katana Pipeline And Middleware Components (A Demo)


If you know ASP.NET Core, you will notice some similarities between that and Katana.  That is because both of them supports OWIN: Katana bringing OWIN support to ASP.NET; and ASP.NET Core natively supporting OWIN.

In this demo, using ASP.NET MVC 5, I registered my OWIN middleware components in the Configuration(IAppBuilder) method of the Startup class declared in Startup.cs by calling one of the these methods: IAppBuilder.Use(), or an IAppBuilder extension method that wraps IAppBuilder.Use(),  or IAppBuilder.Run().  This code explains it a little bit more.

I declared all my OWIN components in a separate file named Startup.MyOWINComponents.cs.  Each component adds a Hello World!!! string in their own language to an OWIN environment variable and awaits the next component in the pipeline, and once the last component is done it passes control back to the previous component until the first component in the pipeline outputs the resulting string to response.  This code explains it a little bit more.

The demo displays the following:

Hello World!!!
Bonjour Tout Le Monde!!!


Leave a Reply

Your email address will not be published. Required fields are marked *