Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpPost]
- public async Task<IHttpActionResult> Test(string name)
- {
- int i = 0;
- i = i + 1;
- return Ok();
- }
- POST http://localhost:8089/api/MyApiController/test
- John
- POST http://localhost:8089/api/MyApiController/test HTTP/1.1
- User-Agent: Fiddler
- Host: localhost:8089
- Content-Length: 26
- Content-Type: application/json; charset=utf-8
- { "name" : "John"}
- HTTP/1.1 405 Method Not Allowed
- Cache-Control: no-cache
- Pragma: no-cache
- Allow: GET
- Content-Type: application/json; charset=utf-8
- Expires: -1
- Server: Microsoft-IIS/8.0
- X-SourceFiles: =?UTF-8?B?QzpcRWNvZmljXFNvbGlkUVxKTExcamxsLW1hcmtldHNwaGVyZVxXZWJzaXRlXGFwaVxTZWFyY2hBcGlcaW5kZXg=?=
- X-Powered-By: ASP.NET
- Date: Fri, 12 Dec 2014 15:51:50 GMT
- Content-Length: 73
- {"Message":"The requested resource does not support http method 'POST'."}
- var content = await Request.Content.ReadAsStringAsync();
- http://localhost:8089/api/MyApi/test
- config.Routes.MapHttpRoute(
- name: "DefaultApi1",
- routeTemplate: "api/{controller}/{action}",
- defaults: new { action="test" }
- );
- [HttpPost]
- public async Task<IHttpActionResult> Test([Frombody]string name)
- {
- int i = 0;
- i = i + 1;
- return Ok();
- }
- { "name" : "somtext"}
- public async Task<IHttpActionResult> Post( [ FromBody ] **object** items )
- {
- Console.WriteLine( items );
- return Ok();
- }
- { "name" : "John" }
- `POST http://localhost:8089/api/MyApiController/`
- User-Agent: Fiddler
- Host: localhost:8089
- Content-Length: 26
- { "name" : "John" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement