ServiceStack工作但Swagger-UI没有

时间:2013-02-20 02:43:10

标签: servicestack swagger

我已经按照ServiceStack(3.9.37)教程创建了一个空的ASP.Net Web应用程序,并使web服务按预期工作:

http://www.somedomain.com:53032/api/metadata

我还在Swagger-UI Package(3.9.35)中链接了

我添加了Plugins.Add(new SwaggerFeature());在AppHost.Configure

我的问题是Swagger-UI不能像我期望的那样可用:

http://www.somedomain.com:53032/swagger-ui/index.html

我收到错误“Handler for Request not found:”with stack trace。

我尝试了目标框架4.0和4.5,结果相同。 Visual Studio版本是2012年

我错过了正确连接的任何内容吗?

1 个答案:

答案 0 :(得分:3)

确定这是一个路径问题。通过以下对web.config的修改解决:

//Added Location node
//path moved here
<location path="api">  // Path moved to location area !!!

<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime/>
<httpHandlers>

//Path returned to wildcard
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>

</httpHandlers>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true"/>
</handlers>
</system.webServer>
</location>