title: DELETE in angularjs - 405 Method not allowed
body: <p>The error I get, which means that it wont execute my delete method from angular:</p>
  
  <pre><code>DELETE http://localhost:49717/api/Item?iid=D1 405 (Method Not Allowed)
  </code></pre>
  
  <p>My app.js</p>
  
  <pre><code>'use strict';
  
  var SalesApp = angular.module('SalesApp', ['ngRoute', 'ngResource']).
       config(['$routeProvider', function ($routeProvider) {
          $routeProvider.
              when('/', { controller: ItemCtrl, templateUrl: 'item.html' }).
              when('/new', { controller: CreateCtrl, templateUrl: 'details.html' }).
              when('/edit/:editId', { controller: EditCtrl, templateUrl: 'details.html' }).
              otherwise({ redirectTo: '/' });
       }]);
  
  SalesApp.factory('Item', function ($resource) {
      return $resource('/api/Item/:id', { id: '@id' }, { update: { method: 'PUT' } });
  });
  
  
  
  
  var ItemCtrl = function ($scope, $location, Item) {    
  
      $scope.delete = function () {
          var id = this.item.iid;
          Item.delete({ iid: id }), function () {
              $('#item_' + id).fadeOut();
          };
      };
  };
  </code></pre>
  
  <p>The appropiate part of the html of the index.html</p>
  
  <pre><code>&lt;tbody&gt;
          &lt;tr ng-repeat="item in items" id="item_{{item.iid}}"&gt;
              &lt;td&gt;{{item.iid}}&lt;/td&gt;
              &lt;td&gt;{{item.name}}&lt;/td&gt;
              &lt;td&gt;{{item.price}}&lt;/td&gt;
              &lt;td&gt;&lt;a ng-click="delete()"&gt;X&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="#/edit/{{item.iid}}"&gt;&lt;div class="edit"&gt;Edit&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  </code></pre>
  
  <p>And my script imports:</p>
  
  <pre><code>&lt;script src="Scripts/jquery-1.9.1.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular-resource.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/app.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular-resource.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular-sanitize.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular-animate.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular-touch.js"&gt;&lt;/script&gt;
      &lt;script src="Scripts/angular-route.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>It may be some silly misstake of me, I'm not quite sure, the add and update works? My first thought was that it could be some foreign key spooking, but I tried deleting an item using sql server and it worked just fine.</p>
  
  <p>Added back-end:</p>
  
  <pre><code>// DELETE api/Item/5
          [ResponseType(typeof(Item))]
          public IHttpActionResult DeleteItem(string id)
          {
              Item item = db.Item.Find(id);
              if (item == null)
              {
                  return NotFound();
              }
  
              db.Item.Remove(item);
              db.SaveChanges();
  
              return Ok(item);
          }
  </code></pre>