ASP.NET web.api man page shows no description

When I run my program, it only shows "Provide a general description of your APIs here." But the content is not showing. As the picture: http://i.stack.imgur.com/unBmb.png

My problem is similar to this ASP.NET Web Api Help Page does not show any tips , but it does not provide any solution.

I completed this tutorial http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages from "Adding Help Pages to an Existing Project", and everything is automatically created from nuGet, except for the "ValuesController".

I guess what the problem is.

My ValuesController:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace WebApiHelperTest.Controllers
{
    public class ValuesController : ApiController
    {
        /// <summary>
        /// Gets some very important data from the server.
        /// </summary>
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        /// <summary>
        /// Looks up some data by ID.
        /// </summary>
        /// <param name="id">The ID of the data.</param>
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
        }
    }
}

- - , ?

( api- asp.net - ( values ​​from start), .)

+4
1

!

1: ControlController Controller, web api2 Controller. :

using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace yournamespace.Controllers
{

public class ValuesController : ApiController
{
    /// <summary>
    /// Gets some very important data from the server.
    /// </summary>
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }

    /// <summary>
    /// Looks up some data by ID.
    /// </summary>
    /// <param name="id">The ID of the data.</param>
    public string Get(int id)
    {
        return "value";
    }
}
}

2: route.config( , api ), .

routes.MapHttpRoute(
        name: "DefaultApi",
        routeTemplate: "api/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional }
        );

, .:)

+2

Source: https://habr.com/ru/post/1608471/


All Articles