问题
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?
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/26882806/asp-net-web-api-self-hosting-owin-katana