i have developed a front end to a RESTAPI using angularjs when i try to write a DELETE using $resource it will give me following error
Method DELETE is not allowed by Access-Control-Allow-Methods.
i have developed a front end to a RESTAPI using angularjs when i try to write a DELETE using $resource it will give me following error
Method DELETE is not allowed by Access-Control-Allow-Methods.
I am also doing the something with angular but I hope this may help you. Here is a solution: First have to update in your API web.config file
<clear />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
<add name="Access-Control-Allow-Methods" value="OPTIONS,GET,POST,PUT,DELETE" />
In `ApiController`
[HttpDelete]
public string Delete()
{
return "u call delete";
}
public HttpResponseMessage Options() {
var response = new HttpResponseMessage();
response.StatusCode = HttpStatusCode.OK;
return response;
}
In Angular...
home.post().then(function (data) {
console.log(data);
});
home.remove().then(function (data) {
console.log(data);
});
Out Put...
> u call delete
Hope this will help you.. :)
you cant access DELETE because its not allow from the server, so: 1. you could change that when you are the owner of the restapi 2. look in the docs of the the API for more information, how to arrive your goal
here is a nice posts to this tobic