There are multiple question I have around self-hosting
Self Hosting Nuget
There are 2 nuget which provide self hosting : Microsoft.AspNet.WebApi.OwinSelfHost
and Microsoft.AspNet.WebApi.SelfHost
, so does microsoft have 2 implementation of self hosting?? or they are same??
Owin or Kitana
the name of nuget is Microsoft.AspNet.WebApi.OwinSelfHost
has OWIN, but as far as I read Owin is an interface and Kitana an implementation, what is the name of the nuget for implementation??
Hosting in Production
I have managed to run the example by creating a console. But when deploying to prod, how to deploy?? Run the exe and keep running console, cant do that. what if somebody closes that console. So should be hosted as part of windows service?? or Is there any other way?
ASP.NET Web API can be either be hosted in IIS or in a separate host process. The former approach is usually appropriate when the Web API is part of a web application and one or more web applications are going to consume it.
This tutorial shows how to host a web API inside a console application. ASP.NET Web API does not require IIS. You can self-host a web API in your own host process. New applications should use OWIN to self-host Web API.
OWIN is a community-owned specification, not an implementation. The Katana project is a set of open-source OWIN components developed by Microsoft. For a general overview of both OWIN and Katana, see An Overview of Project Katana.
Open Web Interface for . NET (OWIN) defines an abstraction between . NET web servers and web applications. OWIN decouples the web application from the server, which makes OWIN ideal for self-hosting a web application in your own process, outside of IIS.
after working on months with webapi/owin I got answers to above questions..
The package to use
Microsoft.AspNet.WebApi.OwinSelfHost
and for hosting better to use topshelf
Topshelf
please read this blog post
NuGet package here clearly states this.
Microsoft ASP.NET Web API 2.2 Self Host 5.2.2 This is a legacy package for hosting ASP.NET Web API within your own process (outside of IIS). Please use the Microsoft.AspNet.WebApi.OwinSelfHost package for new projects.
Anyways, SelfHost is old and is based on WCF stack. OwinSelfHost is new and is based on Katana (name is Katana and not Kitana, BTW).
For production hosting, console app is not practical. You will need to create a Windows service. Take a look at this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With