What is the benefit(s) of self hosted web API? [closed]

爷,独闯天下 提交于 2019-12-08 04:17:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!