Under. NET, create an HTTP service, there are many scenarios, compare old ashx, general handlers (HttpHandler),
Web Service
The data format of the SOAP protocol is the XML,HTTP protocol
Wcf
SOAP-based, data formats are XML and can support a wide variety of protocols, such as Tcp,http,https,named Pipes, MSMQ.
Web API (article presenter)
Simple build HTTP service, the Web API on the. NET platform is an open-source, ideal technology for building rest-ful services that supports MVC features like routing, Controller, action, filter, model binding, inversion of control (IOC), or Dependency injection (DI). Unit tests. These can make the program simpler and more robust, plainly, ASP. NET MVC you will use, then write Webapi, build HTTP service, also wood problematic, lightweight framework, and support for bandwidth-constrained devices such as smartphones.
I have written my own test webservice,wcf,webapi, but because the services built in the work for browsers, mobile phones and so on, is also the. NET platform, so the use of Webapi more. Of course, the use of the road, found that encountered the "pit" also more, of course, not to say Webapi not good, mainly is not familiar with themselves.
- Web API Pit "I'm a damn action, I can't get in the request, and I can't find the HTTP resource matching the request URI"
Attempting to modify the action name in the controller and discovering the Action-public void GetData1 (String data) at the beginning of the class Post,get, but the tricky question is when you continue to add a few action-public void GETDATA2 (string data), public void GetData2 (string data);
At this time my mood is "day dog" is clearly two different action, you are the mother actually prompted me to "found multiple actions matching the request"
Still too young, too little experience, to consult the relevant information,
"Microsoft's Web API is published on the MVC4 project bindings on vs2012, and it presents the Web API
is completely based on the restful standard, completely different from the previous (the same SOAP protocol) WCF and WebService,
It is simple, code readable, and quick to get started, and if you want to compare it to Web services, I would say that its interface
More standard, clearer, no confusing method names, some only a few standard requests, such as Get,post,put,delete
And so on, they correspond to several operations, the following is said:
Get: Raw to Data list (default), or get an Entity data
POST: Add a Service side to add a record that records the entity as a Form object
PUT: Add or modify a record on the service side, record the entity's Form object, and record the primary key to be transferred in a Get mode
Delete: Deletes a record on the service side
Note that the API interfaces exposed above are called in xmlhttprequest cases, and of course you can use jquery's Ajax components
To complete this request invocation, its code is more object-oriented. "
Oh, so, know Webapi is know Get,post,put,delete, (this is I guess, test), add a action,test
To request again,
Several actions were found that matched the request:
Type Service.Controllers.EnterOrExitController of test
Type Service.Controllers.EnterOrExitController of GetData
Type Service.Controllers.EnterOrExitController of Uploaddata
Seems to be wrong, he seems to not care about your action name, you initiate HttpGet request, he put action inside get all out match, http-get-3 throw to you, oh, OMG, "we found a match with the request of the multiple operations, which one do you want?" ”,
Since this is the case, I need to write multiple actions in an API controller to request access, and how to route to the specified action to complete the HTTP request.
The answer is to change the routing configuration file,
You may also find that in this configuration file:
Routetemplate: "Api/{controller}/{id}",
His mother does not prescribe action, so how can not match, others are according to the rest style by default to find Get,post, to the ASP. NET MVC Web, you can only modify to Routetemplate: "api/{ Controller}/{action}/{id} ",
(i) pits in the ASP. NET Web API-"No HTTP resources found matching the request URI"