繁体   English   中英

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

[英]ASP.Net web API Help Page - no content

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

config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

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

protected void Application_Start(object sender, EventArgs e)
{
     AreaRegistration.RegisterAllAreas();
}

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

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);
     }
}

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

ASP.NET Web API帮助页面

介绍

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

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

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

public ActionResult Index()
{
            ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
            return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}

我没有ApiDescriptions。

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

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

你有没有把XMl Path映射到你的右边?

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

这应该有助于您检查WebApi帮助页面描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM