Can I host different ServiceStack services at different URLs

旧城冷巷雨未停 提交于 2019-12-11 09:44:29

问题


When configuring ServiceStack, I have to specify a location (URL) at which my services will be available. E.g. when running side-by-side with WebApi:

<location path="svc">
 <system.web>
   <httpHandlers>
     <add path="*" type="ServiceStack..." verb="*"/>
   </httpHandlers>
 </system.web>

Now all my ServiceStack-based services will be available at http://server/webapp/svc/{route}.

After reading the page about modularizing services into plugins, I was wondering: is it possible to register the service(s) contained in each plugin at a different URL (e.g. vary the /svc/ segment of the URL per plugin)?


回答1:


See the configuring ServiceStack section in Hello World example on how to register ServiceStack to run at a custom path.

You will also want to read the README section and answer if you're trying to run ServiceStack with MVC.


(in response to the comment)

There's only 1 ServiceStack AppHost in every host application, which can only be hosted on 1 root / or /custompath. All other route configurations are mapped from that /path. So if you register it at /svc you can't register a new ServiceStack AppHost from a different mount point e.g. /svc2. If you hosted it at root path / then your individual routes can be hosted at /svc/route1, /svc/route2, etc. But then you wont be able to host it side-by-side with another web fx (e.g. MVC or WebAPI).



来源:https://stackoverflow.com/questions/17358885/can-i-host-different-servicestack-services-at-different-urls

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