Web API as a windows service

前端 未结 1 1767
忘掉有多难
忘掉有多难 2020-12-30 17:43

So I\'m creating a new .Net Framework 4.8 Web API in Visual Studio 2019 and I\'m wanting to know how to create the API as a windows service? I can\'t seem to find any exampl

相关标签:
1条回答
  • 2020-12-30 17:57

    Web API is fully capable of being self hosted on top of OWIN, and does not require IIS to run.

    Web API self hosted is basically just a console app. So the techniques for turning a Web API console app into a Windows Service are the same as for any other .NET console app. You can use a service manager such as NSSM, or create a Windows service project directly (by inheriting from the appropriate classes, pretty messy) or use a library like TopShelf.

    Note that it's generally not a good idea to directly expose this self hosted app directly to the public. IIS provides a lot of security benefits out of the box designed to protect against malicious requests. If you're planning to publicly expose it, make sure you stick a proxy in front of it that will fulfill those security needs.

    0 讨论(0)
提交回复
热议问题