dubs
dubs

Reputation: 6521

Getting 404 error when running $http.delete on development server using angularjs

My $http.delete call is failing with a 404 only when running on out development server - running the website from my own machine is fine.

Here's my code:

application.factory('Task', function ($http) {

    var Task = function (data) {
        angular.extend(this, data);
    }

    Task.deleteTask = function (id) {
        return $http.delete('/api/Tasks/' + id).then(function (response) {
            return response.data;
        });
    }

    Task.prototype.create = function () {
        var result = this;
        return result;
    }

    return Task;

});

Does anyone have an idea what might be the problem?

I'm running the website remotely on IIS 7 and using cassini locally (Visual Studio 2010).

I'm using angularjs from Google's CDN (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js)

Thanks.

Upvotes: 0

Views: 1147

Answers (1)

dubs
dubs

Reputation: 6521

I got this working by adding the following into my web.config:

<system.webServer>
    <handlers>
      <remove name="ExtensionlessUrl-Integrated-4.0" />
      <add name="ExtensionlessUrl-Integrated-4.0"
           path="*."
           verb="GET,POST,DELETE,PUT"
           type="System.Web.Handlers.TransferRequestHandler"
           preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>

Upvotes: 2

Related Questions