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