By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

OWIN: The Changing Face of Web Development in the Microsoft World

The Open Web Interface for .NET (OWIN) is a specification created out of the efforts from the .NET community to build an abstraction between web servers and the .NET framework. ASP.NET until .NET 4.0 was extremely monolithic with a series of pipeline components tightly coupled with IIS. Whether you need them or not, there is no way you could get rid of them and you had to pay for the cost in performance with every request.

The project, code named Katana, and OWIN attempts to solve some of the performance changes with System.web.dll and gives you greater control in porting and hosting applications between different platforms and also makes it very easy to develop and extend.

The number of dependencies that you need to write an OWIN compatible web application is greatly reduced as compared to traditional ASP.NET. When you create an OWIN project you will automatically see the difference.

Note that OWIN components are owned by the community, however project Katana is run by Microsoft (hence the credibility). The OWIN components are part of Owin.dll and are available as a nuget package.

It is very easy to start with OWIN. You can create an empty Web Application project and add the OWIN nuget package using the following command:

install-package Microsoft.Owin.Host.SystemWeb

Once you have successfully installed, you can host the OWIN server in IIS using the IAppBuilder interface. Create a class named "Startup" (it is important to name it this way for OWIN discovery) and add the following code to create the host:

You can now run the application just like any other ASP.NET application and you will notice OWIN running. Note that in this case, OWIN is running in the ASP.NET pipeline, however it is not difficult to switch to a different host.

To create a console host, install the nuget package OwinHost using the command:

Install-package OwinHost

You can now launch the OwinHost.exe from the installed packages folder. Make sure to run it from the project root to allow the host to search for an OwinStartupAttribute assembly. You are now all set to run OWIN from a console host. You will see the same output as earlier, just that it is no longer using the ASP.NET pipeline. This is very powerful. In a future post we will explore some very interesting capabilities that the Katana project is throwing at us!