This article is a mirror article of machine translation, please click here to jump to the original article.

View: 34525|Reply: 1

[WebAPI] WebAPI for .NET Core

[Copy link]
Posted on 4/16/2019 9:33:57 AM | | |
1. Controller inherits from the same controller as MVC; The route configuration is , annotated on the Controller
[Route("api/[controller]")], mark [HttpGet], [HttpPost], etc. on the method, or use [HttpGet("{id}")]
This is the style. You can use the method [HttpPost("Test")] to mark the method. This is how it works
http://localhost:54689/api/values/Test 访问。
2. Action supports IActionResult as the return value, but does not support HttpResponseMessage as the return value
3. IHttpControllerSelector is no longer supported, and multiple versions are implemented with IApplicationModelConvention
Write a NameSpaceVersionRoutingConvention
Then visit http://localhost:57799/api/v1/Default/Test, http://localhost:57799/api/v2/Default/Test
After debugging, it was found that NameSpaceVersionRoutingConvention is only executed once when the process is started, unlike this
IHttpControllerSeelct, so it doesn't need to be run every time you request an access, so it's more efficient!
4. Filter and asp.net mvc core are shared, and there are two synchronous and asynchronous interfaces under Microsoft.AspNetCore.Mvc.Filters. Built
Discuss using asynchronous ones. Then register as follows






Previous:Game of Thrones season 8
Next:MySQL queries the database and the amount of space occupied by each table
Posted on 10/28/2021 10:57:52 AM |
Learned,!! Thank you
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com