這里就直接截圖了,如下(很簡單的操作):
1:Get幾種請求
2:Post
3:Put
4:Delete
最后,雖然簡單,代碼還是給放一下(這里只是拋磚引玉的作用,自己可以根據自身的業務需要來做進一步的優化和封裝):

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using WebApplication.Models; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace WebApplication.Controllers { [Route("api/[controller]")] public class ValuesController : Controller { // GET: api/<controller> [HttpGet] //public IEnumerable<string> Get() //{ // return new string[] { "value1", "value2" }; //} //// GET api/<controller>/5 //[HttpGet("{id}/{name}")] //public string Getother(int id, string name) //{ // return "id=" + id + ", name=" + name; //} //[HttpGet("{id}")] //public string GetByid(int id) //{ // return "value" + id; //} public string Get(Mystu student) { return student.name; } // POST api/<controller> [HttpPost] public void Post(string type, [FromBody]Mystu student) { string temp = type + $"id={student.id},name={student.name}"; } // PUT api/<controller>/5 [HttpPut()] public void Put(int id, [FromBody]Mystu student) { string pstr = $"id={id},sid={student.id},name={student.name}"; } // DELETE api/<controller>/5 [HttpDelete("{id}")] public void Delete(int id) { string temp = $"長官{id}說:我們要把壞分子給清除掉"; } } public class Mystu { public int id { get; set; } public string name { get; set; } } }
5:新增文件上傳
6:PostMan請求參數為枚舉類型
枚舉之外 取不到就為假,假就為0了,或者是默認值
枚舉的類: