Note that there are some explanatory texts on larger screens.

plurals
  1. POAttributeRouting: Why is my POST, but not my PUT routed?
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/10099270/asp-net-web-api-returns-404-for-put-only-on-some-servers">ASP.NET Web API returns 404 for PUT only on some servers</a> </p> </blockquote> <p>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 <a href="http://nuget.org/packages/AttributeRouting" rel="nofollow noreferrer">the AttributeRouting project</a> (perhaps best explained <a href="http://www.strathweb.com/2012/05/attribute-based-routing-in-asp-net-web-api/" rel="nofollow noreferrer">here</a>) to set up my routes.</p> <p>I have set up the following method for POST:</p> <pre><code>[POST("bank/{id}")] public void Post(int id, BankRequest bank) { // Create a new Bank here } </code></pre> <p>When calling this from <a href="http://fiddler2.com/fiddler2/" rel="nofollow noreferrer">Fiddler</a> 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.</p> <p>Then I have a similar method for PUT:</p> <pre><code>[PUT("bank/{id}")] public void Put(int id, BankRequest bank) { // Update a Bank here } </code></pre> <p>The problem is that I get a HTTP 404 Not Found message when calling this. All I do is send <strong>exactly</strong> 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.</p> <p>Does anyone know why?</p> <p>Please note that I am setting up an API defined by others, so I have to support PUT.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload