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

Sir*_*uck 7 c# asp.net asp.net-web-api asp.net-web-api-helppages

我从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.

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

kdu*_*bau 13

我能够通过添加GlobalConfiguration.Configure (WebApiConfig.Register);我的Application_Start ()方法来解决这个问题.因为我的应用程序使用OWIN,所以我只在注册我的API Startup.Configuration (IAppBuilder app).


Per*_*eru 0

您正确映射了 XMl 路径吗?

您是否在方法中添加了摘要?/// /// 从服务器获取一些非常重要的数据。///

这应该会有所帮助 你检查过WebApi 帮助页面描述了吗