1

Possible Duplicate:
ASP.NET Web API returns 404 for PUT only on some servers

I have created a new ASP.Net MVC4 solution to use the new Web API functionality. I have a controller inheriting from ApiController and I am using the AttributeRouting project (perhaps best explained here) to set up my routes.

I have set up the following method for POST:

[POST("bank/{id}")]
public void Post(int id, BankRequest bank)
{
    // Create a new Bank here
}

When calling this from Fiddler I can debug this in Visual Studio 2012 and see that everything works as expected. I can see the id is correct and that the json is automatically serialized correctly into my BankRequest object. All very nice, I think. GET also works as expected.

Then I have a similar method for PUT:

[PUT("bank/{id}")]
public void Put(int id, BankRequest bank)
{
    // Update a Bank here
}

The problem is that I get a HTTP 404 Not Found message when calling this. All I do is send exactly the same url and json in, just changing from POST to PUT. All I do in Fiddler is change from POST to PUT, so my url and json are preserved. When I switch back to POST it works fine as well. I don't know if it is the fancy AttributeRouting that does not work or if something else is incorrect.

Does anyone know why?

Please note that I am setting up an API defined by others, so I have to support PUT.

Community
  • 1
  • 1
Halvard
  • 3,891
  • 6
  • 39
  • 51
  • What do you use for hosting?asp.net development server (Cassini), IIS Express, IIS? – nemesv Jun 29 '12 at 07:32
  • I am hosting this in IIS, version 7.5.7600.16385, on a Windows 7 Enterprise version 6.1 SP1. – Halvard Jun 29 '12 at 07:33
  • Yes, indeed it is a duplicate. Kevin Ortman's answer solved my problem. I will vote to close my question. Thanks, nemesv. – Halvard Jun 29 '12 at 07:50

0 Answers0