Wednesday, July 24, 2013

Katana? OWIN? What? Here's what and how to get started with them too...

In my last post I mentioned Katana, Katana Lifts Its License - Katana v2 nuget bins will not be restricted to Windows only..., but what IS it, you ask?

Pablo M. Cibraro (aka Cibrax) - Getting started with Owin and Katana

The .NET ecosystem offers today a lot of alternatives for developing web applications. You can either use any of the frameworks supported by Microsoft with ASP.NET such as Forms, MVC or Web API, or any other open source alternative like FubuMVC, ServiceStack, NancyFx or OpenRasta to name a few. From an architecture standpoint, all these frameworks have three main layers in common (in spite of the difference with the implementation details), hosting, middleware, and application.

The hosting layer is responsible for managing the underline process, where the http connections are established and managed, and also to materialize those connections into request/response objects that are sent to the upper layers. For example, the hosting layer could be ASP.NET running in IIS, or it could also be a console application that uses the http listener directly.

The middleware layer provides common infrastructure services, which runs at low level in the http stack, such as security, caching, or any other concern that can be handled at this level.

The application layer is where the applications or services are implemented using the features available in the framework.

However, the distinction between the middleware and application layers is not always clear, which causes that many of the middleware services end up being implemented in the application layer. For example, you could implement middleware services for security in ASP.NET MVC using filters, which rely on features specific to the application level in that framework. This make almost impossible to reuse all these services across all the available frameworks, so you will find different implementations of the same services for the different frameworks. To give an example, basic authentication is something that could be implemented as middleware service and reused, but today is implemented differently in each framework.

Someone would suggest that a ASP.NET Http Module could be a good option for implementing a middleware service, but that’s not necessarily true as it would only work when the hosting layer uses ASP.NET.

This exact problem is what OWIN specification tries to address by providing a common abstraction for any http-aware service or application with minimal dependencies on existing frameworks or implementations.  At very core level, OWIN defines a handler, which is represented as an application delegate...

...

Katana is a Microsoft implementation of the OWIN specification, which includes handlers for the hosting and middleware layers. It’s an open source project, which can be found in this location. All the investment that Microsoft has done so far for ASP.NET in the different application frameworks (i.e. MVC or Web API), it’s now being refactored as OWIN handlers that can be reused across different application frameworks. For example, cookie authentication or even OAuth are being implemented as middleware services that can be reused not only by ASP.NET web apps but also for other application frameworks in the open source world.

...

imageimageimage..."

There you go!

No comments: