Gartner has predicted that worldwide information security spending will witness a growth of 7% in 2017, with the total amount spent reaching close to $93 billion in 2018. This in...
By: Amit Dabli | February 24, 2016
OWIN stands for Open Web Interface for .NET . OWIN is an abstraction between .NET web servers and web applications. It decouples the application from the server, making it ideal for self-hosting. OWIN can serve as host for webapi, nancy or even as ftp server.
· Host application in your own process, independent of IIS e.g. in a windows service.
· Easily port application between hosts and potentially entire platforms/operating systems.
· Reduces middle ware components, works as pipeline transparently.
· Simple workflow due to pipelines, and improved efficiency due to reduce pipeline.
OWIN provides the following general definitions for OWIN-based application:
OWIN is a community-owned specification, not an implementation. The Katana project is Microsoft’s implementation of OWIN.
This tutorial shows how to host ASP.NET Web API in a console application, using OWIN to self-host the Web API framework.
Step 1 : Create a project and install Nugets
Create a project of type Console Application, to host our webapi using own.
We are using topshelf to host owin inside a windows service.
Step 2: Setup Webapi
Also register the controller with route provider, using
Step 3: Register the web application with Owin
To register webapi with owin, create a class OwinConfiguration.cs
Step 4: Host owin inside windows service
Topshelf hosts OWIN as console application while debugging using visual studio.
To register OWIN with topself create below class
Also change the main method as below
Step 5: Test
Visit the URL http://localhost:8099/api/HelloWorldApi in your favorite browser to make sure it works.