I am stuck with Web API 2 controller, from which I call PUT
method and it gives me an error that method isn't allowed. I added lines of code in Web.config
that prevent WebDAV to block methods. I tried everything but it is not working. It is probably problem with my PUT
method in a controller.
Here is my controller code:
public IHttpActionResult Put(int id, [FromBody]ArticleModel model) {
var article = _articleService.UpdateArticle(model);
return Ok<ArticleModel>(article);
}
This is a code from where I call put :
response = await client.PutAsJsonAsync("api/article/2", articleModel);
before this code I defined client as http and added needed properties, and called other controller methods (GET, POST, DELETE) , they all work. This is from Windows Form app, and I am also calling from Postman but still the same error.