Alibabacloud.com offers a wide variety of articles about asp net web api rest tutorial, easily find your asp net web api rest tutorial information here online.
Recently, I found that web APIs are very popular, and there are various great gods in the park who are already studying them. I saw a series of tutorials on the official asp.net website /. So I plan to keep learning and record the learning process in the blog and share it with you.
After each article, I share the code.
As I was just getting started, I have limited technical capabilities. If you have any questions, let's discuss them.
I. Using Entity
Series Navigation Address http://www.cnblogs.com/fzrain/p/3490137.html
Once the API is released, the consumer will start to use it and mix it with other data. However, changes are inevitable when new requirements arise. You may be glad that the API changes have not been affected on the existing client, but this situation will not happen all the time.
Therefore, it is necessary to carefully consider the
Note:This article is part of the [ASP. NET web API series tutorial]. If this is the first time you read this series of tutorials, read the previous content first. Batching handler for ASP. NET
Series Navigation Address http://www.cnblogs.com/fzrain/p/3490137.html
Digress: This technical point is newly learned and does not belong to the original series. However, with the help of the Project Background of the original series, the external series is named, some new technologies may be added to this series in the future.
In Web Api 2.0, A New Route configuration method is proposed-Attribute-based
Reference page:Http://www.yuanjiaocheng.net/ASPNET-CORE/core-static-files.htmlHttp://www.yuanjiaocheng.net/ASPNET-CORE/setup-mvc.htmlHttp://www.yuanjiaocheng.net/ASPNET-CORE/mvc-design-pattern.htmlHttp://www.yuanjiaocheng.net/ASPNET-CORE/mvc-routing.htmlHttp://www.yuanjiaocheng.net/ASPNET-CORE/attribute-route.htmlNote: This article is part of the ASP. NET Web
Note: This article is part of the ASP. NET Web API Series tutorial, if you are looking at this blog post for the first time, please look at the previous content first.2.4 Creating a help Page for a Web API2.4 Creating the
Reference page:Http://www.yuanjiaocheng.net/CSharp/csharprumenshili.htmlHttp://www.yuanjiaocheng.net/entity/mode-first.htmlHttp://www.yuanjiaocheng.net/entity/database-first.htmlHttp://www.yuanjiaocheng.net/entity/choose-development-approach.htmlHttp://www.yuanjiaocheng.net/entity/query-with-edm.htmlNote: This article is part of the ASP. NET Web
Reference page:Http://www.yuanjiaocheng.net/webapi/create-crud-api-1-delete.htmlHttp://www.yuanjiaocheng.net/webapi/Consume-web-api.htmlHttp://www.yuanjiaocheng.net/webapi/mvc-consume-webapi-get.htmlHttp://www.yuanjiaocheng.net/webapi/mvc-consume-webapi-post.htmlHttp://www.yuanjiaocheng.net/webapi/mvc-consume-webapi-put.htmlNote: This article is part of the ASP.
,api to check the Header and compare it to the ETag value saved by the response, this response generates a new etag, and the response contains the new ETag.Then the customer 1 for the put update operation, its If-match header value is the value of the ETag obtained by the customer before 1, after reaching the API, the API will know that this is not the same value
mentioned above can also be processed.CodeFor reference, Chinese problems are complicated and need to be handled according to specific situations: Httpresponsemessage response = task. result;
Mediatypeheadervalue contenttype = response. content. headers. contenttype;
If (
String . Isnullorempty (contenttype. charset ))
{
Contenttype. charset =
"
GBK
" ;
}
7. Links
ASP. net mvc
Note:This article is part of the [ASP. NET web API series tutorial]. If this is the first time you read this series of tutorials, read the previous content first. 5.1 HTTP message handlers
5.1 HTTP message processor
This article cited from: http://www.asp.net/
better to do a service, and you can inject it.Look at the code:This class is relatively simple to talk about, do not forget to register in the startup.Then inject and use it inside the controller, and don't forget to modify the Createcountryuri method:Test:Ok.Shape a single resourceThis is similar to the principle of the set, first set up an extension method:You can modify the action again:Test:Is easy to use, I will not test more.For data shaping it is important to take the ID with you as much
response, this response generates a new etag, and the response contains the new ETag.Then the customer 1 for the put update operation, its If-match header value is the value of the ETag obtained by the customer before 1, after reaching the API, the API will know that this is not the same value as the resource's latest etag, so the API returns 412 precondition Fa
Controllers folder to store the controller.In the subsequent chapters we will further elaborate on the Controller's code. The following are some of the basic functions that the controller implements:For example, here's an HTTP request to get a ToDo project:GET Http://localhost:5000/api/todo http/1.1User-agent:fiddlerhost:localhost:5000Here is the response stream:http/1.1 OKContent-type:application/json;charset=utf-8server:microsoft-httpapi/2.0Date: T
=" 610 "height=" 241 "title=" image "style=" border-width:0px; "alt=" image "src=" http:/ Images.cnitblog.com/blog/139239/201502/050938002963700.png "border=" 0 "/>For example, here's an HTTP request to get a ToDo project:GET Http://localhost:5000/api/todo http/1.1User-agent:fiddlerhost:localhost:5000Here is the response stream:http/1.1 OKContent-type:application/json;charset=utf-8server:microsoft-httpapi/2.0Date:thu, Oct 22:40:31 GMTcontent-length:46
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.