ASP.Net Web API帮助页面区域返回空输出 [英] ASP.Net Web API Help Page Area returning empty output

查看:113
本文介绍了ASP.Net Web API帮助页面区域返回空输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个预先存在的MVC应用程序,我使用Nuget添加了Web API和Web API Self Documentation。虽然Web API控制器可以正常工作(返回对HTTP请求的有效响应),但Help控制器找不到任何要记录的Web API方法。



在 Help controller Index Action中Configuration.Services.GetApiExplorer()。ApiDescriptions将返回0个结果。 ?



帮助区域是与我的应用程序其余部分分开的区域。这是否导致找不到控制器的零件找不到我的控制器?此外,我什至在HelpController本身上添加了一个帮助,但仍然没有API描述。



我的API控制器也有特殊的路由,所以我我不确定是否相关。

解决方案

经过更多搜索后,我发现这篇文章,它也引用了这篇文章



如第一篇文章所述,一瞥就是罪魁祸首,此变通办法为我解决了这个问题: Glimpse.axd
< inspectors>
< ignoredTypes>
< add type = Glimpse.AspNet.Inspector.RoutesInspector,Glimpse.AspNet />
< / ignoredTypes>
< / inspectors>
< / glimpse>

这也是一个已知问题,此 Glimpse GitHub问题


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.

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

The Help Area is a separate area from the rest of my application. Is this causing the piece that finds the Controllers to not find my controllers? Furthermore, I even added a help snipped to the HelpController itself, which still resulted in no API descriptions.

I do also have special routing for my API controllers, so I'm not sure if that's relevant.

解决方案

After some more searching i found this post which also refers to this post

As mentioned in the first post, Glimpse is the culplit, this workaround solved the issue for me:

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

This is also a known issue and the workaround is described on this Glimpse GitHub Issue.

这篇关于ASP.Net Web API帮助页面区域返回空输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆