[英]ASP.Net web API Help Page - no content
I installed the package from NuGet, uncommented the line from HelpPageConfig.cs- 我从NuGet安装了包,从HelpPageConfig.cs-取消注释了该行
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
I've set the same file under Properties->Build->XML documentation file, Added a new Global.asax.cs file in which I call for registration for all the areas under Application_Start method: 我在Properties-> Build-> XML文档文件下设置了相同的文件,添加了一个新的Global.asax.cs文件,我在其中调用了Application_Start方法下所有区域的注册:
protected void Application_Start(object sender, EventArgs e)
{
AreaRegistration.RegisterAllAreas();
}
I've added some summary for some of my controllers: 我为我的一些控制器添加了一些摘要:
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);
}
}
when i run the webpage and go to '/help' the only thing i see is 当我运行网页并转到'/ help'时,我唯一看到的是
ASP.NET Web API Help Page
ASP.NET Web API帮助页面
Introduction
介绍
Provide a general description of your APIs here.
在此处提供API的一般说明。
and an empty page after that... 然后是一个空页......
I tried to debug that and in HelpController.cs in: 我尝试调试它并在HelpController.cs中:
public ActionResult Index()
{
ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}
I get no ApiDescriptions. 我没有ApiDescriptions。
what am I missing? 我错过了什么? I'll appreciate any help!
我会感激任何帮助!
I was able to solve this by adding GlobalConfiguration.Configure (WebApiConfig.Register);
我能够通过添加
GlobalConfiguration.Configure (WebApiConfig.Register);
来解决这个问题GlobalConfiguration.Configure (WebApiConfig.Register);
in my Application_Start ()
method. 在我的
Application_Start ()
方法中。 Because my application uses OWIN I was registering my APIs only in Startup.Configuration (IAppBuilder app)
. 因为我的应用程序使用OWIN,所以我只在
Startup.Configuration (IAppBuilder app)
注册我的API。
Have you mapped you XMl Path right ? 你有没有把XMl Path映射到你的右边?
Have you added summary to your methods ? 您是否在方法中添加了摘要? /// /// Gets some very important data from the server.
/// ///从服务器获取一些非常重要的数据。 ///
///
This should help Have you checked WebApi Help Page Description 这应该有助于您检查WebApi帮助页面描述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.