With the introduction of OWIN and self hosting, microsoft has really opened a lot of possible doors for developers and application users. This post is targetted to have an OWIN application hosted in Windows Service. Also we would be configuring the SSL for the Site.
Source code can be accessed at: GitHub
Creating a Windows Services Project
This is pretty straightforward. In visual Studio, Create new project and select Windows Service as project. This will add a project with default Service “Service1”. Rename to whatever the name expected.
Add OwinSelfHost and WebApi2
In the Tools-> Nuget package Manager -> PM console type in the following command to get the WebApi and self host packages referenced.
Install-Package Microsoft.Aspnet.WebApi.OwinSelfHost
This will install and reference all the required packages and dependencies. Also we need one more package to debug and use some functions like welcome package. For this import the Microsoft.Owin.Diagnostics using PM Console.
Install-Package Microsoft.Owin.Diagnostics
Also, to Enable Cross Origing Resource Sharing, we need to import the following package:
Install-Package Microsoft.Owin.Cors
At this point the we are Good to Start.