OWIN
Open Web Interface .Net (OWIN) defines a standard interface between a .NET web server and web applications. it is a community-owned and open-source project. OWIN is designed to decouple the relationship between an ASP.NET application and IIS by defining a standard interface. If the web server id decouples from the application framework then we can use the application with a different web server and other components.
Layers
The following describes the layers of an application that the OWIN Specification is built on.
The approach travels from the bottom to the top.
Host
The function of the host is to create the pipeline by fetcheing the configuration information from our application. The host is responsible for starting the process.
Server
The HTTP server directly communicates with the client and then uses OWIN rules to process the request. the server binds to a port and listens for the request. It receives the request and passes the request in the pipeline that our application has configured. IIS is an example of both a Host and a Server.
Framework
The web framework may require an adapter layer that converts from OWIN rules. The Application Framework provides a development model to our application. MVC ia an example of such a framework.
Application
Application is the application that we are developing. The preceding component-based approach is to decouple the web server from our application that gives us multiple options to use any component for any of the various layers. This is in contrast to the coupling between System.Web and IIS. We can swap System.Web with Web Listener, IIS with a Console Application, MVC with WebAPI without effecting our existing application.
OWIN Components
There are only two main pieces in OWIN.
A Environment Dictionary
The Environment dictionary helps create the decoupling OWIN architecture. This dictionary is passed to our application by the server with the request and response header and bodies. Our application interacts with this dictionary instead of communicating with the server. The environment dictionary must not be null. Keys must be compared using StringComparer.Ordinal.
A generic Function Delegate
This delegate take a dictionary parameter and returns a task. We can plug-in a different middle wear component using this. The environment dictionary can contain only the designated keys. Some of the keys related to the Request are the following:
| Key | Description |
| "owin.RequestBody" | A stream with the request body |
| "owin.RequestMethod" | A string containing the HTTP methods |
| "owin.RequestHeaders" | A I Dictionary<string,string[]> |
| "owin.RequestPath" | A string that contain the request path |




Atul RawatPosted Jan 11, 2015, 11:04 PM
thnks vithal sir
Vithal WadjePosted Jan 10, 2015, 1:57 PM
good explanation,keep it up
Jasminder SinghPosted Jan 10, 2015, 1:58 AM
Can u provide an example or a situation to explain what exactly is OWIN ?