經過建立「待辦事項」的任務演示,咱們能夠學會並掌握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