自助式网络API的优点是什么? [英] What is the benefit(s) of self hosted web API?

查看:244
本文介绍了自助式网络API的优点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实!我提出这个问题只是知道,如果我有一个解决方案,有一个API项目,许多其他的确切方法主机?
为什么我们需要自我托管?

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

推荐答案

我在Windows控制台和Windows服务类型的程序(守护程序)中使用web-api的自承载。这种类型的应用程序是长时间运行的进程,没有任何UI,可以在不安装IIS角色的情况下运行。

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.

好处是web-api控制器可以直接

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该应用程序正在运行(您可以使用单独的监控服务,通过web-api ping请求轮询应用程序,并通过电子邮件向您发出警告)

  • 当前请求应用程序状态(调试/诊断目的)

  • 向外部服务提供REST API

  • 提供一些UI - 页面应用程序)并使用REST请求来使用UI的数据。

  • 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.

此外,我在MS-SQL的特定场景中使用了web-api DB <--->应用程序交互:

Also I have used web-api in specific scenarios of MS-SQL DB <---> Application interaction:


  • 从Sql Server 2012开始,您不能在.NET存储过程中使用WCF

  • 在Sql Server 2005和2008中,您可以使用WCF,但是当您在服务器上更新.NET Framework时会出现错误(SQL Server中的程序集版本不同从GAC中的程序集版本错误)。

  • web-api是这里的resque,因为您可以使用 System.Net.WebClient类在您使用SQL Server 2005和更高版本的存储过程中没有任何限制。

  • 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.

这篇关于自助式网络API的优点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆