asp.net-web-api – 在WebApi2帮助页面中启用文档

我有一个简单的webapi2项目.

我似乎发现自己的唯一信息是指较旧的webapi1

如果我有我的控制器

/// <summary>
    /// Gets a list of not very interesting @R_945_4045@ion
    /// </summary>
    /// <returns>The list</returns>
   [ResponseType(typeof(ExampleModel))]
    public IHttpActionResult Get()
    {
        var data = new List<ExampleModel>()
        {
            new ExampleModel()
            {
                Date = DateTime.Now,Name = "Tom"
            },new ExampleModel()
            {
                Date = DateTime.Now.AddDays(-20),Name = "Bob"
            }
        };

当我尝试浏览帮助页面时,为什么没有信息出现.我被告知没有可用的文件.

是否有一个神奇的开关可以打开这些数据的自动填充?

解决方法

如果你提到显示xml评论,那么你可以在这里找到我的答案:

ASP.NET Web API Help Page documentation using Xml comments on controllers

请务必在Areas / HelpPage / App_Start / HelpPageConfig.cs中取消注释此代码

// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

还要确保xml文件位于App_Data而不是bin中,它认位于项目属性

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....