asp.net web api self hosting / owin / katana - asp.net-web-api

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?

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.

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

Related

How to host ms bot created in c# or composer in windows service?

We must use C# MS bot in windows service. How to implement it in .Net core for MSBot SDKv4?
All samples using IIS/Azure App service as hosting platform.
They're aren't any examples or samples that show how to explicitly do this. But you should be able to follow articles such as this or this and then tweak as needed. It shouldn't be much different than hosting any other asp.net core application.
The two points to make sure and cover are:
Make sure that the bot/application is configured (whether in appsettings.json or otherwise) so that it has the right configuration data. Specifically appid/password
Ensure the endpoint can be hit by the connector/channels.

How to config Service and UI view

Reference to my previous question: Can't compile the project. Missing so many files
I am very new to .NET core version. So I have so a few questions need someone to guide me to a quick start.
There are 2 templates version for ASP.NET core 2.0; .NET core and .NET full. Does it mean if I choose the .NET full version, I still can use 3rd party DLL such as iTextSharp or EPPlus version, doesn't it? 'Cause I have read that with .NET core, all 3rd party DLL without .NET core support could not be used in the project.
From the download template, it contains 2 main projects, one is .NET core service and another is angular UI view. Currently, it set to localhost for all API calls. Because I run the window server in my VM and run the client on my host so I need to set the client to look for the service on my VM via IP address. Which file do I need to config?
Related to Q2, how to config the .NET service to run in production mode and install into IIS server?
Thx in advance for all comments and suggestions.
Answer to the second question;
There's a config file in src/assets/appconfig.json
You can change those values...
remoteServiceBaseUrl: Used to configure base address of the server
side APIs. Default value: http://localhost:22742
appBaseUrl: Used
to configure base address of the client application. Default value:
http://localhost:4200
appBaseUrl is configured since we use it to define format of our URL. If we want to use tenancy name as subdomain for a multi-tenant application then we can define appBaseUrl as
Aspnet Zero Angular Getting Started
PS: Apart from the framework configuration; be aware that connecting something in VM is another discussion. You need to set some settings like Bridged Networking... You can figure it out in the related VM's board.
For point 1 you can refer this post.
For Point 2: You can host your service application on Azure or IIS so
that you can consume your service from other PC.
For Point 3, Its pretty well explained here.
Additional: If you want to deploy Angular application, you can refer Deployment of Angular Application
You can also refer src/assets/appconfig.json for required configurations.

When to self host ASP.NET Web API

While reading a blog I found that ASP.NET Web API could be self hosted. There are loads of links telling how to self host Web API but I could not find any link explaining when it makes sense over IIS. Could someone please point me to couple of scenarios where self hosting of Web API is more suited than IIS hosting.
Thanks,
Ravi
Generally speaking, you would use self hosted Web API to get a better performance and to get rid of unnecessary pipelines of IIS. Additionally, you get better control over handling http requests, configuration and so forth. Since you have less dependencies on other apps your deployment and troubleshooting gets easier and less complicated.
Having said that, you have to write code to handle everything, even simple things (such as returning static files) that are simply done by IIS.
Thanks to the ASP.net Core, you'd be able to host your apps on Linux, MacOS and Windows. So, going cross platform would be another reason for using self hosted apps.

WebAPI/OWIN hosting confusion

There are so many things today? I'm looking to host web api in windows service but recently I come across this link http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
is this a new thing and should we use this OWIN, Please suggest?
Does this OWIN make thing more faster or what are the benefit to use OWIN?
OWIN makes things a bit simpler and cleaner when self-hosting.
You might want to check out the OWIN Web API 2 self host in windows service example on GitHub.
Web API is based on owin, and owin is an abstraction. Instead of those old times when web api team was responsible for making web api availble on several hosts such as IIS, self host, etc, it just relays on owin. Owin has several implementations based on IIS, ASP.NET, ASP.NET Core, Self Host etc.
For example see the following sample of running asp.net web api odata on asp.net core using owin & kestrel: https://github.com/ymoradi/OwinAspNetCore
After doing more searching OWIN and Kanata are just layers on top particularly WebAPI, they are rather an convenient composer from what I understand from here http://msdn.microsoft.com/en-us/magazine/dn451439.aspx
for my purpose, I use WebAPI ONLY, so I don't need all these extra things.

Deploy ASP.Net site to windows server

I have been developing an ASP application which I have almost finished. It accesses a SQL database on a Windows sever on AWS. I would like to deploy my application to AWS though.
Does anyone have any suggestions about how I should do this?
Refer to the Deploying an asp.net application thread that contains all necessary information and step-by-step instructions on how to accomplish this task.
If you are deploying an MVC application, check whether the hosting provider provides the support for MVC hosting. Just right-click on the solution and select Publish. Then copy the files into the hosting space.

Resources