我可以在不同的URL托管不同的ServiceStack服务吗 [英] Can I host different ServiceStack services at different URLs
问题描述
配置 ServiceStack,我必须指定一个位置(URL),我的服务将在该位置可用。例如。与WebApi并排运行时:
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>
现在我所有基于ServiceStack的服务都可以在 http://上获得服务器/ webapp / svc / {路由}
。
Now all my ServiceStack-based services will be available at http://server/webapp/svc/{route}
.
阅读有关模块化服务到插件中,我想知道:是否可以在不同的URL上注册每个插件中包含的服务(例如,不同每个插件的URL的 / svc /
段)?
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)?
推荐答案
请参阅Hello World示例中的配置ServiceStack部分,以了解如何注册 ServiceStack以自定义路径运行。
See the configuring ServiceStack section in Hello World example on how to register ServiceStack to run at a custom path.
您还需要阅读自述文件部分并回答如果您尝试使用MVC运行ServiceStack。
You will also want to read the README section and answer if you're trying to run ServiceStack with MVC.
(响应comme nt)
每个主机应用程序中只有1个ServiceStack AppHost,只能托管在1个根 / $ c上$ c>或
/ custompath
。所有其他路由配置均从该 /路径
映射。因此,如果您在 / svc
中注册它,则无法从其他安装点注册新的ServiceStack AppHost,例如 / svc2
。如果您将其托管在根路径 /
中,则您的单个路由可以托管在 / svc / route1
, / svc / route2
等。但是,您将无法与另一个Web FX(例如MVC或WebAPI)并排托管它。
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).
这篇关于我可以在不同的URL托管不同的ServiceStack服务吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!