0

I have isolated the problem down to a few lines. With IIS express it calls the PUT on the web API. When I switch to using IIS with the same code the call to the PUT method never happens.. The GET call works with both just fine.. any idea?

  $scope.save = function (msa) {
        $scope.msa = msa;
        var id = this.msa.PlaceId;

        Msa.update({ id: id }, $scope.msa, function () {
            alert('finished update'); //only gets here with iis express
            $scope.updatedItems.push(id);
            $location.path('/');
        });
    }

MsaApp.factory('Msa', function ($resource) {
    return $resource('/api/Place/:id', { id: '@id' }, { update: { method: 'PUT' } });
});

EDIT 1:

I thought it was working but now it only works when 'localhost' and not the computer name.. it is not calling the server method.. any ideas what things to look out for that make the site act differently from localhost to ? .. and even stranger.. the angular site wont load in IE.. but it loads in chrome

EDIT 2:

I think I have the answer.. The dewfault webapi PUT/UPDATE creates invalid code.. It sort of randomly would breaking at db.Entry(place).State = EntityState.Modified... I found code here that seems to fix it so far.. not exactly sure what it does though

An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key

Community
  • 1
  • 1
punkouter
  • 5,170
  • 15
  • 71
  • 116
  • Please provide more info: If $scope.updatedItems.push(id) has not been made at all, then there must be some error in your code, please check in the console; otherwise, check the network and see if Msa.update is initiated. – geniuscarrier Aug 29 '13 at 21:25
  • Key Value Response HTTP/1.1 405 Method Not Allowed – punkouter Aug 29 '13 at 22:10
  • That means angular is fine. But server side is not functioning well. – geniuscarrier Aug 29 '13 at 22:12
  • its all the defaults for IIS.. I never changed anything.. and it happens on my machine as well as the VM 2012 server.. so not sure what to do.. maybe I can use post instead of put ? though Im not sure how to change angular to do that for the update – punkouter Aug 29 '13 at 22:14
  • see if this helps: http://stackoverflow.com/questions/6147181/405-method-not-allowed-in-iis7-5-for-put-method – geniuscarrier Aug 29 '13 at 22:18

2 Answers2

1

IIS does block some of the actions by default, I believe PUT is one (DELETE is another).

See: https://stackoverflow.com/a/12443578/1873485

Go to Handler Mappings in your IIS Manager. Find ExtensionlessUrlHandler-Integrated-4.0, double click it. Click Request Restrictions... button and on Verbs tab, add both DELETE and PUT.

Community
  • 1
  • 1
TheSharpieOne
  • 25,646
  • 9
  • 66
  • 78
1

Remove WebDAV module from IIS, it should work

Amitava
  • 5,013
  • 9
  • 37
  • 50