Techbubbles

What is Katana and OWIN for ASP.NET?

Katana is not a revolutionary new project in ASP.NET world. It is just a next step in ASP.NET, The points that drive to go for Katana and OWIN are, Basically ASP.NET was optimised for two types of customers one classing ASP developers and second one LOB(line of business app) developers. From the beginning it was expected to run these applications under IIS(internet information services). Challenges are, as ASP.NET is part of .NET Framework which is shipping in every two to three years and the Web is moving little faster than .NET FW. How do you get these new web concepts faster to customers? The way that ASP.NET was built everything was put in to one assembly System.Web. It is highly coupled. More over all the features in this assembly are turned on by default, you have to explicitly turn it off for those features that you do not like. There is only one hosting option ie IIS.

Solution 1 OOB ASP.NET MVC come out of from the .NET FW and enabled more rapid ship cycle. MVC was not shipped as part of .NET FW and it is shipping with Nuget.

Solution 2 Break Dependency This was came with Web API.Designed to break the dependency with System.Web. Web API has no dependencies on System.Web and it is completely decoupled.

So the need for Katana is Modern Web applications needs the ability to compose multiple frameworks in a single server. When you think about Modern Web Applications you have got static HTML files, Web API, Rendering engines like MVC and SignalR. The burden of all these four things self-hosting independently spinning of four processes so the idea is take these four and compose them into a single pipe-line then you can host in self-host or IIS.

What is Katana?

Katana is a set of components for building and running Web applications on a common hosting abstraction. The hosting abstraction is OWIN.

What is OWIN?

OWIN is Open Web Interface for .NET. It is a specification around this hosting abstraction. The primary interface in OWIN is called the application delegate. The main goal of Katana is portability and it is achieved by reducing the abstraction with as few primitives as possible.OWIN application is made up of four logical layers

image  

at the very bottom you have the host and it is job is managing processes.Server process the requests through an OWIN pipeline.The Application Framework is going to implemented as a regular OWIN pipeline component. Basically it is programming model for developers.

For Example: If you build a Web API application and Web API just provides it own OWIN endpoint.

Katana Components are

image

IIS is a process manager. OwinHost is a standalone executable that can start up an OWIN application. The new thing is WebListener which is ultra light-weight server component where you can expect pretty amazing performance results.

Katana goals are

Composability

Portability

Performance and Scalability

image

The server starts up and immediately it looks for your Apps code which your app is going to create a pipe-line for like Auth, Static files or Web API and returned that back to the server. The requests are go through these pipelines.

Startup conventions are

image

By default the FW looks Startup class which has got a method Configuration which takes a IAppBuilder interface type. call use method to call your pipeline.

Portability(Host/Server flexibility)

image image image

You can do all those above combinations without really re-compiling your application.

Create an empty ASP.NET Web application in Visual Studio 2012 and install some components as shown in the following screenshot

image

Install some helpful OWIN extensions

image

Now create a class called Startup and add the configuration method

image

At present you need to add a configuration line to web.config, eventually you do not need to do this in release version

image

Run the application you see hello world in browser, now you self-host this application without changing anything. first install the following package

image  

You no need to recompile your application, what it does is it just put the above assembly in bin folder.

image

if you want to use the WebListener then install the following package

image

Now say the below command to host it

image

For WebAPI application install the following package

image

Write the below code for creating OWIN Web API end point

image

Katana components are in pre-release now and they are going to available in summer. More on Katana can be read here

what katana does is, it enables a bunch of things,it does not replace everything  that you know infact, it is definitely not throwing everything that you know about ASP.NET.

Reference Howard Dierking’s talk at channel 9.

 

 

 


Related Posts:

%d bloggers like this: