Why is POST data lost when sent from a custom 404 page in IIS 6.0?

I built a custom 404 CMS system in .NET 3.5, and while publishing data is done locally in IIS 5.1 and 6.0, it doesn't work on IIS 6.0 server. I have compared the site elements of the IIS 6.0 site for each element and they are almost identical, only the differences do not matter.

I have verified that the POST-ing form matches " http: //domain/folder/folder/page.resource " in each case (the code is in SVN) and that no redirects occur on submission (I made exceptions to be sure). Some debug info by server:

IIS 5.1 (my computer, works):
ServerVariables["REQUEST_METHOD"]="POST"
Request.TotalBytes = 1600
Request.QueryString.Count = 1 (NOTE: contains "404;http://domain:80/folder/folder/page.resource" in each case)
Request.Form.Count = 109

IIS 6.0 (test server, works):
ServerVariables["REQUEST_METHOD"]="GET" (NOTE: IIS 6.0 reads this as "GET" instead of "POST")
Request.TotalBytes = 1600
Request.QueryString.Count = 1
Request.Form.Count = 109

IIS 6.0 (production server, does not work):
ServerVariables["REQUEST_METHOD"]="GET"
Request.TotalBytes = 0 (NOTE: should be ~1600)
Request.QueryString.Count = 1
Request.Form.Count = 0 (NOTE: should be 109)

      

Does anyone have any ideas? I read that POST data is not sent to IIS 7.0 for 404 pages, but not 6.0. My form is in this format:

<form id="GolfRegistration" name="GolfRegistration" method="POST" action="/folder/folder/page.resource" onSubmit="return CalculateAmount();">
<input type="button" value="Submit" onClick="if(ValidateInput()){submit(GolfRegistration);}">
</form>

      

For IIS 5.1 only, I install the .resource extension in "IIS> Website> Properties> Home tab> Config Button> Add" to work with GET, HEAD and POST. This prevents me from getting 405 errors on submit ...

Edit: I changed POST to GET and in all 3 cases it passed the data correctly, so this is not a form issue. Unfortunately, I cannot pass variables (there are 109) in the request.

+1


source to share


2 answers


I had the same problem and unfortunately it looks like the answer is "it's a feature".

More details here: Ok, I tried to post a link to the problem description, but it says "new users cannot post links." So the best thing I can do is google search for "IIS 6: form data missing from 404/405 error handler" (make sure it's in quotes) and, at least at the time of my writing, the top result should be the page I was linking to.

In general, what happens:

1) Your non-existent URL is POST'd (e.g. mydomain.com/somepage) 2) IIS receives the request, notes that some page does not exist, and then fires a second request to your error handler, and the method for that request is inside , GET. And none of your POST data gets passed.

This leaves the question of why you have success in IIS 6 - this puzzled me.



Anyway, read the link above for.

By the way, I am running PHP on IIS 6 / Windows2003 and I came across an interesting workaround. Although PHP does not receive POST variables from IIS (as you would expect), PHP still has access to the raw input stream identified by "php: // input" from which it can read the original request body. This will contain the POST variables in their raw format - I was able to use the PHP parse_str () function to get the POST variables from that raw string.

So something like this could be done in ASP.NET. Have you tried checking Request.InputStream? If my memory serves me correctly, this will give you a stream that you can read. Maybe it will have raw POST data?

-Josh

+2


source


Try to temporarily change the form method to GET . This should indicate if any data is being sent and what data is being sent.



I ran into a similar issue before and ended up with the issue with the script creating the content being sent, not when submitting the data.

+1


source







All Articles