经过建立“待办事项”的任务演示,咱们能够学会并掌握ASP.NET Core的相关知识。api
待办事项的功能以下:测试
using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; namespace Course001.Controllers { [Route("api/[controller]")] [ApiController] public class TodosController : ControllerBase { [HttpGet] public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } [HttpGet("{id}")] public string Get(int id) { return "value"; } [HttpPost] public void Post([FromBody] string value) { } [HttpPut("{id}")] public void Put(int id, [FromBody] string value) { } [HttpDelete("{id}")] public void Delete(int id) { } } }
此时WebApi项目已经完成,并经过Postman能够对接口进行各类测试。spa