问题
Actually! I'm putting this question Just to know that what is the exact ways to host if i have a solution and there is a API project any many others? And exactly why we need self hosting?
Please Guide me Thanks
回答1:
I use self-hosting of web-api in windows console and windows service type of programs (daemons). Such type of applications are long-running processes that doesn't have any UI and can run without installing IIS role.
The benefit is that web-api controllers can have direct access to your application's data.
Possible use cases for self-hosting when you have such app are:
- ping that application is running (you can have separate monitoring service that will poll your applications with web-api ping request and warns you with emails)
- request of current application's status (debug/diagnostics purpose)
- provide REST API to external services
- provide some UI - you can return static pages implemented as SPA (Single Page Application) and use REST requests to consume data for UI.
Also I have used web-api in specific scenarios of MS-SQL DB <---> Application interaction:
- starting with Sql Server 2012 you cannot use WCF in .NET stored procedures (you get error on installing stored procedure that uses WCF).
- in Sql Server 2005 and 2008 you can use WCF, but errors will occurs when you update .NET Framework on server (assembly version in SQL Server differs from assembly version in GAC error).
- web-api is the resque here because you can use System.Net.WebClient class in your stored procedures with SQL Server 2005 and later without any restrictions.
来源:https://stackoverflow.com/questions/29226331/what-is-the-benefits-of-self-hosted-web-api