0

-Settings

IIS 7.5 and Visual Studio 2012 4.5

I have create the first webAPI project on my machine. With the code below I can change the type of verb to POST or GET and the request to the server and the response back to the client work perfectly.

As the code is below I keep getting eaither a 405 error code or a 404 not found error code.

My question is is their some type of setting that I need to add to the .config file or a setting that I need to make on the iis7.5 web server so I can get this working?

I have Google this over and over and cannot find the answer to this question.

In my JavaScript file on the client.

  $.ajax(
                     {
                         url: "/api/project",
                         type: "PUT",
                         contentType: "application/json",
                         data:'3',
                         success: function (result) {
                            alert(result);
                         }
                     });

In the controller in c# class

   public void Put(int intt)
    {
        var obj = intt;
    }
Vinyl Windows
  • 503
  • 1
  • 7
  • 19

3 Answers3

3

Found the magical , elusive link.

http://geekswithblogs.net/michelotti/archive/2011/05/28/resolve-404-in-iis-express-for-put-and-delete-verbs.aspx

I take that back I am getting another server 500 error.

See error below. This one is driving me loco...

IIS 500 Error

Vinyl Windows
  • 503
  • 1
  • 7
  • 19
  • 1
    This solved my problem. It's so ridicilous that Web API provides default GET, POST, PUT and DELETE methods but IIS restricts it. – Gaui Nov 27 '12 at 20:44
0

Seems like you might need to disable the WebDAV service. See here:

Enabling html PUT method on IIS 7.5

Community
  • 1
  • 1
Eric Petroelje
  • 59,820
  • 9
  • 127
  • 177
0

I had the 500 error too and after reading this post, I found that if I altered the Content-Type to "application/json" the 500 error code disappeared.

However, I wanted "text/plain" to work, so I followed the tutorial here and I got it to work successfully.

I hope this helps.

Community
  • 1
  • 1
Ryan Penfold
  • 752
  • 2
  • 11
  • 16