启用.NET MVC HTTP PUT请求 [英] Enable Http PUT requests on .NET MVC
问题描述
我工作的MVC应用程序。在我原来服务的草案我在其中一个控制器有此方法:
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)
这工作得很好。在最新版本我已经要求换穿PUT请求这从它使用后有类似的附加的机制区别开来。所以我改成了这样:
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)
突然,我从只是改变了AcceptVerbs让我的请求404,所有的。从错误的外观,它看起来好像IIS正试图将请求路由作为一个标准的web表单页面,而不是使用MVC扩展名的URL重写。
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.
谷歌搜索这似乎是一个常见的原因是不允许PUT请求浏览器,但我不使用浏览器来测试这个 - 我使用招。所以应该没有问题存在。我也认为正确的设置都已经在web.config:
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?
编辑:这code工作的同事们的机器上。所以它看起来像我的本地IIS中设置为有过错。仍处于亏损解释什么,我需要改变,虽然 - 任何想法
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?
干杯,
马特
推荐答案
涉及的WebDAV我找到了答案另一个让家人站点更无觅处和死胡同后:)
After much fruitless searching and blind alleys involving WebDAV I found the answer on another SO family site :)
<一个href=\"http://serverfault.com/questions/93424/how-to-enable-put-and-delete-in-iis7\">http://serverfault.com/questions/93424/how-to-enable-put-and-delete-in-iis7
这篇关于启用.NET MVC HTTP PUT请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!