I'm working on an MVC application. On my original draft of the service I had this method in one of my controllers:
[AcceptVerbs(HttpVerbs.Post)]
[ActionName("UpdateRelationship")]
public ActionResult UpdateRelationship(string aParameter)
And that worked fine. In the latest revision I've been asked to change this into a PUT request to differentiate it from a similar add mechanism which uses post. So I changed it to this:
[AcceptVerbs(HttpVerbs.Put)]
[ActionName("UpdateRelationship")]
public ActionResult UpdateRelationship(string aParameter)
And suddenly I'm getting a 404 on my requests, all from just changing the AcceptVerbs. From the look of the error, it appears as though IIS is trying to route the request as a standard webforms page rather than using MVC extensionless url re-writing.
Googling this it seems that a common cause is browsers not allowing PUT requests but I'm not using a browser to test this - I'm using Fiddler. So there should be no problem there. I also think the correct settings are already in the web.config:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="UrlRoutingHandler" />
<remove name="MvcHttpHandler" />
<remove name="WebDAV" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
<security>
<requestFiltering>
<verbs>
<add verb="PUT" allowed="true" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
So what have I missed?
EDIT: This code works on a colleagues' machine. So it looks like my local setup of IIS as at fault. Still at a loss to explain what I need to change though - any ideas?
Cheers,
Matt
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…