Saturday, April 18, 2015

Katana and OWIN Middleware

Katana is the Microsoft implementation of OWIN that appeared with Visual Studio 2013 (MVC 5).

Prior to Katana, ASP.NET has been built on top of IIS (inetinfo.exe) that provides the hosting and infrastructure features for Web applications. It runs with the SYSTEM account on the Web Server. IIS itself has been around longer than ASP.NET. To make it work with ASP.NET it uses aspnet_isapi.DLL that communicates with an ASP.NET worker process using named pipes.

IIS 7+ uses aspnet_wp.exe which runs with the ASPNET account and which is responsible for hosting the different application domains for ASP.NET.

Over the years ASP.NET and IIS have evolved to provide a wide range of features from authentication to hashing, encryption, compression, caching, configuration, web sockets, logging, diagnostics etc. Even within a specific feature like diagnostics there are multiple methods like logging, request monitoring, tracing et al. NOT EVERYONE needs all these features - and that is the whole idea behind the OWIN middleware framework and Katana.

As HTML5 standards continues to mature, we are seeing a shift in Web Architecture. More and more processing is happening client side rather than on the server. Instead of the Server doing heavy processing and generating all the html, it is responding to only ajax requests that sends out just raw data! This is also true for mobile applications that consume these data with their native apps.The end result is developers are looking for a fast, efficient, lightweight and extensible host for the Web applications and Web Services, particularly with cloud based services where you pay for every byte and CPU cycles.

Like Linkedin does using Node.JS and HTML5 to build better and faster apps. It is easy to add a package to Node and make it run a lean and mean web server using a fraction of traditional resources on server side. It is also easier to scale because it consumes just the resources it needs.

Katana follows this architecture unlike ASP.NET MVC which relies on one giant core System.Web assembly on every project. Instead of one large assembly, Katana features are highly modular and componentized so you can add only the features you need for your project.

Katana allows you to create and plug in your middleware components by being agnostic of whether they are hosted in a console app or in IIS etc. More and more middleware components like Cookie Authentication have been developed for Katana moving away from dependence on ASP.NET MVC modules and handlers and filters etc .

To use and  host your Katana custom components in IIS, create the component  with the Startup class as a DLL with its build  target pointing at the /bin folder in your project or solution. For more information and Katana components, look at the Katana open source project in codeplex.

To learn more about Katana, there's an excellent course by Scott Allen @pluralsight
http://www.pluralsight.com/courses/aspdotnet-mvc5-fundamentals


No comments:

Post a Comment