ASP.Net Web API Help Page returning empty output

2019-04-21 17:36发布

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

2条回答
爷、活的狠高调
2楼-- · 2019-04-21 17:41

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>
查看更多
走好不送
3楼-- · 2019-04-21 17:57

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.

查看更多
登录 后发表回答