views:

867

answers:

2

I built a Custom 404 CMS system in .NET 3.5, and while posting data works locally in IIS 5.1 and 6.0, it does not work on the production IIS 6.0 server. I compared the IIS 6.0 site settings item by item, and they are nearly identical, with the only differences not mattering.

I verified that the form is POST-ing to "http://domain/folder/folder/page.resource" in each case (code is in SVN) and that no redirects occur when submitted (I was throwing exceptions to make 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 have read about POST data not being submitted in IIS 7.0 for 404 pages, but not in 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 setup the .resource extension in "IIS > Website > Properties > Home Directory tab > Configuration button > Add" to work with GET, HEAD, and POST. This prevents me from getting 405 errors when submitting.

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

+1  A: 

Try temporarily changing the form method to GET. This should tell you if any data is being sent and what data is being sent.

I've come across a similar issue before, and it ended up being a problem with the script generating the content being sent, rather than when the data was sent.

Matt
I changed it to GET and it is sending the data in the querystring in all 3 instances.
+1  A: 

Hi JStevenson,

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

Read more here: Ok, I tried to post a link to the issue description, but it says 'new users can't post links.' So instead, the best I can do is this: do a Google search for "IIS 6: Form Post Data Missing in 404/405 Custom Error Handler" (make sure it's in quotes), and at least at the time of my writing this, the top result should be the page I was referring to.

In summary, what is happening is:

1) Your non-existent URL is POST'd to (e.g., mydomain.com/somepage) 2) IIS receives the request, notes that somepage doesn't exist, and it then fires up a second request to your error handler, and the method for that request is, internally, GET. And none of your POST data is passed along.

That leaves the question as to why you are every having success on IIS 6--that has me baffled.

At any rate, read the above link for more.

Incidentally, I'm running PHP on IIS 6/Windows2003, and I discovered an interesting workaround. While PHP does not receive the POST variables from IIS (as you would expect), PHP still has access to a raw input stream, identified by "php://input", which it can read the original request body from. This will contain the POST variables, in a raw format--I was able to use PHP's parse_str() function to get the POST variables out of that raw string.

So, it might be possible to do something similar in ASP.NET. Have you tried inspecting Request.InputStream? If my memory serves me correctly, that will give you a stream that you can read from. Maybe it will have the raw POST data?

-Josh