I have a preexisting MVC app that I added Web API and Web API Self Documentation using Nuget. While the Web API controllers function fine (return valid responses to HTTP requests) the Help controller is not finding any Web API methods to document.
我有一个预先存在的MVC应用程序,我使用Nuget添加了Web API和Web API自我文档。虽然Web API控制器运行正常(返回对HTTP请求的有效响应),但帮助控制器未找到任何要记录的Web API方法。
In the Help controller Index action "Configuration.Services.GetApiExplorer().ApiDescriptions" is returning with 0 results.
在帮助控制器索引操作“Configuration.Services.GetApiExplorer()。ApiDescriptions”中返回0结果。
I even went as far as copying the entire "HelpPage" area from another functioning web app.
我甚至从其他功能正常的网络应用程序复制整个“HelpPage”区域。
What populated ApiDescriptions and are there any config settings I need to set to expose my api to documentations?
填充ApiDescriptions的是什么,我需要设置任何配置设置以将我的API暴露给文档吗?
Things I have tried:
我尝试过的事情:
- Reinstalling nuget packages
- 重新安装nuget包
- Copying over HelpPage area from working project
- 从工作项目复制HelpPage区域
- Copying over routes from working project
- 从工作项目复制路线
- Comparing references from working project to broken project
- 比较工作项目和破碎项目的参考
- Comparing Global.asax.cs from working project to broken project
- 将Global.asax.cs从工作项目与破坏的项目进行比较
- Comparing web.config's from working project to broken project
- 将web.config从工作项目与破坏的项目进行比较
2 个解决方案
#1
7
It turns out my Glimpse MVC 4 installation was interfering. This is a known issue with Glimpse and Web API Help Pages. Uninstalling Glimpse fixes the problem.
事实证明我的Glimpse MVC 4安装干扰了。这是Glimpse和Web API帮助页面的已知问题。卸载Glimpse可以解决问题。
#2
3
The link provided by William also provides the following work-around in this comment which worked for me:
William提供的链接还提供了以下解决方案,该评论对我有用:
For now, you can use a simple workaround by ignoring the RoutesInspector. Just add this to your web.config:
现在,您可以通过忽略RoutesInspector来使用简单的解决方法。只需将其添加到您的web.config:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<inspectors>
<ignoredTypes>
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
</ignoredTypes>
</inspectors>
</glimpse>
#1
7
It turns out my Glimpse MVC 4 installation was interfering. This is a known issue with Glimpse and Web API Help Pages. Uninstalling Glimpse fixes the problem.
事实证明我的Glimpse MVC 4安装干扰了。这是Glimpse和Web API帮助页面的已知问题。卸载Glimpse可以解决问题。
#2
3
The link provided by William also provides the following work-around in this comment which worked for me:
William提供的链接还提供了以下解决方案,该评论对我有用:
For now, you can use a simple workaround by ignoring the RoutesInspector. Just add this to your web.config:
现在,您可以通过忽略RoutesInspector来使用简单的解决方法。只需将其添加到您的web.config:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<inspectors>
<ignoredTypes>
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
</ignoredTypes>
</inspectors>
</glimpse>