小编Sir*_*uck的帖子

ASP.Net web API帮助页面 - 没有内容

我从NuGet安装了包,从HelpPageConfig.cs-取消注释了该行

config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
Run Code Online (Sandbox Code Playgroud)

我在Properties-> Build-> XML文档文件下设置了相同的文件,添加了一个新的Global.asax.cs文件,我在其中调用了Application_Start方法下所有区域的注册:

protected void Application_Start(object sender, EventArgs e)
{
     AreaRegistration.RegisterAllAreas();
}
Run Code Online (Sandbox Code Playgroud)

我为我的一些控制器添加了一些摘要:

public class IncidentsController : ApiController
{
     /// <summary>
     /// this is the summary
     /// </summary>
     /// <param name="incidentId">this is incidentId</param>
     /// <returns>it returns something</returns>
     [Route("{incidentId}")]
     [HttpGet]
     public object GetIncidentById(int incidentId)
     {
            return Incidents.SingleOrDefault(i => i.id == incidentId);
     }
}
Run Code Online (Sandbox Code Playgroud)

当我运行网页并转到'/ help'时,我唯一看到的是

ASP.NET Web API帮助页面

介绍

在此处提供API的一般说明.

然后是一个空页......

我尝试调试它并在HelpController.cs中:

public ActionResult Index()
{
            ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
            return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}
Run Code Online (Sandbox Code Playgroud)

我没有ApiDescriptions.

我错过了什么?我会感激任何帮助!

c# asp.net asp.net-web-api asp.net-web-api-helppages

7
推荐指数
2
解决办法
4209
查看次数