ASP.Net Web API Help Page returning empty output

梦想的初衷 提交于 2019-12-06 21:36:19

问题


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.

In the Help controller Index action "Configuration.Services.GetApiExplorer().ApiDescriptions" is returning with 0 results.

I even went as far as copying the entire "HelpPage" area from another functioning web app.

What populated ApiDescriptions and are there any config settings I need to set to expose my api to documentations?


Things I have tried:

  • Reinstalling nuget packages
  • Copying over HelpPage area from working project
  • Copying over routes from working project
  • Comparing references from working project to broken project
  • Comparing Global.asax.cs from working project to broken project
  • Comparing web.config's from working project to broken project

回答1:


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.




回答2:


The link provided by William also provides the following work-around in this comment which worked for me:

For now, you can use a simple workaround by ignoring the RoutesInspector. Just add this to your web.config:

<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<inspectors>
      <ignoredTypes>
        <add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
      </ignoredTypes>
    </inspectors>
</glimpse>


来源:https://stackoverflow.com/questions/17958959/asp-net-web-api-help-page-returning-empty-output

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