加入webapi.helppage包,但apiexplorer没有找到任何 [英] webapi.helppage package added but apiexplorer is not finding anything
问题描述
我有我已通过添加 webapi.helppage
包是一个 .NET 4.5的MVC 4
项目的NuGet。
I have a .NET 4.5 MVC 4
project which I have added the webapi.helppage
package to it via NuGet.
然后添加了一个 ApiController
来的我下面的项目:
Then added an ApiController
to my project of the below:
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string Get(int id)
{
return "value";
}
// POST api/values
public void Post([FromBody]string value)
{
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
}
要查看是否帮助页是否正常运行,但它返回一个空的 apidescription
收集以下 GetApiExplorer()
电话:
to see if the help page is working, but it returns an empty apidescription
collection for the below GetApiExplorer()
call:
public ActionResult Index()
{
return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}
我可以但是通过导航到 / API /值
例如。
任何人都知道为什么 apidescription
将不会被发现?
Anyone know why the apidescription
wouldn't be found?
推荐答案
我犯了一个新的Web API项目,并开始在我安装的NuGet将包一个接一个,它原来掠影
是什么原因造成这些不显示。
I made a new web api project and started adding in my installed NuGet packages one by one and it turns out Glimpse
is what is causing these not to display.
我发现了更多的信息在这里:<一href="http://stackoverflow.com/questions/17958959/asp-net-web-api-help-page-returning-empty-output">ASP.Net网络API帮助页面返回空输出
I found more information here: ASP.Net Web API Help Page returning empty output
和最合适的工作,各地至今的下方添加到的web.config
窥见部分:
and the most appropriate work around so far is to add the below to the web.config
glimpse section:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<inspectors>
<ignoredTypes>
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
</ignoredTypes>
</inspectors>
</glimpse>
这篇关于加入webapi.helppage包,但apiexplorer没有找到任何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!