The HTTP verb POST used to access path '[my path]' is not allowed
I am receiving an er开发者_如何学运维ror that states: "The HTTP verb POST used to access path '[my path]' is not allowed.".
The error is being caused by the fact that I am implementing an HTML form element that uses the POST method and does not explicitly define an .aspx page in its ACTION parameter.
For example:
<form action="" method="post">
<input type="submit" />
</form>
The HTML above is on a file at "/foo/default.aspx".
Now, if the user points the URL to the root directory "foo" without specifying the aspx file (i.e. "http://localhost/foo") and then submits the form, the error "The HTTP verb POST used to access path '/foo' is not allowed." will be thrown.
However, if the user goes to "http://localhost/foo/default.aspx" and then submits the form, all goes well (even if the ACTION parameter is left empty).
Note: If I explicitly add the name of the .aspx (default.aspx) page to the ACTION parameter, no errors are thrown. So the example below works fine regardless if the user defines the name of the file in the URL or not.
<form action="default.aspx" method="post">
<input type="submit" />
</form>
I was curious as to why the error was being thrown, so I read a Microsoft KB that states
This problem occurs because a client makes an HTTP request by sending the POST method to a static HTML page. Static HTML pages do not support the POST method.
I suppose the core of the explanation makes sense, however in my case, my form is not being sent to a static html page - it's being sent to the same page that the html form lives on (default.aspx)... this is implicit to an ACTION param that is left empty.
Is it possible to configure IIS (or otherwise) that will allow us to do form POSTing and keep the ACTION param empty?
Check your default documents - without specifying the action, it might be stripping back to foo/
. If you've got a default document (ie: Default.html, not Default.aspx) that is static it might cause this issue.
Try using "./" as your action.
It's been a year since initially experienced this error and thought I should add to this post that I am no longer receiving the error.
I don't know what fixed the problem, but my guess is that the error has gone away due to some Windows Update that has been implemented on my dev machine within the year.
One thing I noticed in the IIS 7 settings is that the "ISAPI.DLL" (in the "Handler Mappings" section) is disabled. I can't figure out how to "enable" it in order to try to reproduce the problem to show that the ISAPI.DLL is causing (or related) to the problem.
Anyway, the I am unable to reproduce this error that occurs when I leave the "action" attribute blank in an HTML Form tag. So, my guess is that there is an IIS and/or .NET Framework update that implicitly or explicitly fixes the error mentioned in the OP.
I had the same thing happen -- by having action = " " in the form tag. Don't know how it got in there. Sometimes when I edit a gridView it doesn't "sync" with the HTML. Maybe this is what happened. Weird. Took me a while to find, too!
The ASP.Net ISAPI DLL was plugged-in to translate all (*) URLs so had to follow these steps:
- Click on the website
- Choose Properties and on Virtual Directory tab click Configuration
- Remove the ASP.Net ISAPI DLL (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll)
- Restart IIS and try again.
I got this error when I was setting up a custom HTTP handler, not using forms. You have to let IIS (or your WebDevServer in VisualStudio) know that you handling certain pages with your own handler. This is done by adding entries to the web.config file. I could type them out, but life is short and the sun is over the yard-arm, so here's a link - but scroll down to "Registering the Custom HTTP Handler in IIS ". Or read the whole thing, as it's all good, meaty tech-nuggets...
http://msdn.microsoft.com/en-us/library/ms227433%28v=vs.100%29.aspx
Hope that helps.
Add an index.htm with below re-direct lines
<html>
<head>
<meta http-equiv="Refresh" content="0; url=Default.aspx" />
</head>
</html>
精彩评论