Swagger 生成API doc Failed。

1> HttpVerb and Route Atribute are required to decorate the Action 否则无法生成 api

 

 

namespace FirstWebAPI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class HomeController : ControllerBase
    {
        [Route("")]
        [HttpPost]
        public IActionResult Index()
        {
            /* method implementation*/
            return Ok();
        }

        [Route("contact")]
        [HttpGet]
        public IActionResult Contact()
        {
            /* method implementation*/
            return Ok("Contact");
        }
    }
}

上一篇:MVC中返回json数据的两种方式


下一篇:ASP.NET Core http请求内容过大, IIS服务器 返回 Request Too Long 解决方案