只需将此部分添加到Web.config中,对path / {* pathInfo}的所有请求都将由指定的处理程序处理,即使pathInfo中有点也是如此。(摘自ServiceStack MVC主机Web.config示例,此答案为https://stackoverflow.com/a/12151501/801189)
这对于IIS 6和7均适用。您可以通过修改“添加”元素中的path =“ *”,将特定处理程序分配给“路由”之后的不同路径。
<location path="route">
<system.web>
<httpHandlers>
<add path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ApiURIs-ISAPI-Integrated-4.0" path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</location>