简体   繁体   English

具有自托管或 IIS 选项的 WebAPI

[英]WebAPI with either self-hosted or IIS option

I have a WebAPI that is currently self-hosted.我有一个当前自托管的 WebAPI。 I also made an IIS version of it as a separate project.我还将它的 IIS 版本作为单独的项目制作。

What I want to do is, combine these two projects into one solution and based on a setting I can apply, compile it either as self-hosted or IIS.我想要做的是,将这两个项目组合成一个解决方案,并根据我可以应用的设置,将其编译为自托管或 IIS。

What would be the best way to achieve this?实现这一目标的最佳方法是什么?

Is there any concern to use only one hosting model in your IIS?Since switch hosting model need to change hostingmodel attribute and application pool CLR version.在您的 IIS 中仅使用一个托管 model 是否有任何顾虑?由于切换托管 model 需要更改托管模型属性和应用程序池 CLR 版本。 So I think host your WebAPI under two different sub-application would be a solution.所以我认为在两个不同的子应用程序下托管您的 WebAPI 将是一个解决方案。 So that they can use diffferent hosting model and choose different application pools.以便他们可以使用不同的托管 model 并选择不同的应用程序池。

https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/ https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/

I ended up having two separate projects in the same solution and the IIS project linking to the files ( models, controllers, services etc.) in the Self-hosted project which seems to work pretty good!我最终在同一个解决方案中有两个单独的项目,并且 IIS 项目链接到自托管项目中的文件(模型、控制器、服务等),这似乎工作得很好!

Thanks for the answers.感谢您的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM