?
Solved

POST data lost when submitting from a Custom 404 page in IIS 6.0...reason?

Posted on 2009-04-28
19
Medium Priority
?
930 Views
Last Modified: 2013-11-08
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 box.  I compared the IIS 6.0 site settings item by item, and they are nearly identical, with the only differences not mattering.

The URLs for my pages are setup like "http://domain/folder/folder/page" and to avoid 405 errors (since posting to a item without an extension isn't allowed by default) I redirect to a .resource page such as "http://domain/folder/folder/page.resource".  I created this in IIS with these settings:

IIS > Website > Properties > Home Directory tab > Configuration button > Add
Executable: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
Extension: .resource
Limit to: GET, HEAD, POST
Script Engine: Yes
Check that file exists: Yes

I verified that the form is POST-ing to "http://domain/folder/folder/page.resource" 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 (contains "404;http://domain:80/folder/folder/page.resource")
Request.Form.Count = 109

IIS 6.0 (test server, works):
ServerVariables["REQUEST_METHOD"]="GET"
Request.TotalBytes = 1600
Request.QueryString.Count = 1 (contains "404;http://domain:80/folder/folder/page.resource")
Request.Form.Count = 109

IIS 6.0 (product server, does not work):
ServerVariables["REQUEST_METHOD"]="GET"
Request.TotalBytes = 0
Request.QueryString.Count = 1 (contains "404;http://domain:80/folder/folder/page.resource")
Request.Form.Count = 0

Does anyone have any ideas?  I have read about POST data not being submitted in IIS 7.0, but not in 6.0.
0
Comment
Question by:andculture
  • 8
  • 5
  • 3
16 Comments
 
LVL 22

Expert Comment

by:cj_1969
ID: 24269726
You keep referencing POST data but on your test and production server you are reporting it as a GET.
I don't know that this matters as the test server is working but these are 2 different methods and if you are coding specifically around a POST procedure then you could run into problems with this.
0
 

Author Comment

by:andculture
ID: 24269939
All 3 forms are setup with a method of POST, but in IIS 6.0 that POST is somehow viewed as a GET when reading ServerVariables["REQUEST_METHOD"].  As I listed above, even though the development 6.0 server thinks it is GET data, it still loads 109 values into the Request.Form.  Thanks for clarifying.

(I am using SVN to ensure that all page setups and frameworks are identical.)
<form id="GolfRegistration" name="GolfRegistration" method="POST" action="/folder/folder/page.resource" onSubmit="return CalculateAmount();">
<input type="button" value="Submit" onClick="if(testAction()){submit(GolfRegistration);}">
</form>

Open in new window

0
 

Author Comment

by:andculture
ID: 24304893
I still haven't found resolution to this problem (or even why IIS 6.0 believes the POST is a GET).  Any experts out there? ;)
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 22

Expert Comment

by:cj_1969
ID: 24305164
Try changing the syntax of your submit statement.
What you have might be working but the correct syntax is:
document.form.submit()

Depending on the patching on the systems, they might have changed something that is making your current syntax not work.

Older versions of IIS, being less secure, are more likely to allow less tightly controlled code to work also.
0
 

Author Comment

by:andculture
ID: 24306201
Using "document.GolfRegistration.submit();" did not change the result on the production server; posted data is still lost.
0
 
LVL 22

Expert Comment

by:cj_1969
ID: 24307517
If this is a custom application extension that you are using for a single purpose, what about removing the GET from Extension definition.

From what I have read, GET and POST pass the data from the page to the server in different formats.
Based on the code you have working, you have coded for a POST action where the variables and values are obtained in a specific manner.  My guess is that the browser IS doing a GET when it sends the data which is making the data unavailable to the calls you have in your code.

Based on that we need to get the page to do the submission using a POST and my guess is the problem should be resolved.
0
 

Author Comment

by:andculture
ID: 24307860
I removed the GET so that the .resource extension is setup to limit to HEAD and POST.  This did *not* make a difference when submitting on the production IIS 6.0 server.  Remember, this *is* working on our test IIS 6.0 server.

I decided to drop the "HEAD" also, and this also gave the same result on prod/test IIS 6.0.  I then completely removed the .resource extension mapping and it still worked the same.  It turns out that only IIS 5.1 needs this mapping, and it needs it for both GET and POST since that form submits to itself.
0
 

Author Comment

by:andculture
ID: 24365472
I never found a solution and had to write a file with the 404 code in it to the location with the form.  If I find an actual solution I will post it here.
0
 
LVL 1

Accepted Solution

by:
jbeallva earned 2000 total points
ID: 24453786
Hi JStevenson,

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

Read more here:
http://www.eggheadcafe.com/software/aspnet/32116082/custom-404-handler-unable.aspx

In summary, what is happening is:

1) Your non-existent URL is POST'd to (e.g., http://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 *ever* 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", from 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
0
 

Author Comment

by:andculture
ID: 24453872
On Tuesday I will have to see if I can get anything from Request.InputStream.  Thanks for the input, and yes, I am confused too as to why IIS 6.0 worked in one case and not another.
0
 
LVL 22

Expert Comment

by:cj_1969
ID: 24472742
One thought ... if this is an IIS 6 specific issue you could try running the site under IIS 5 isolation mode. Maybe this will get the feature back again.
0
 

Assisted Solution

by:andculture
andculture earned 0 total points
ID: 24474595
jbeallva: Request.InputStream.Length=0, so I can not read the data that way.

cj_1969: In this case the client's server hosts about a dozen sites, only a few of which we control, so running under IIS 5 isolation mode isn't an option.

Thanks for the suggestions.
0
 
LVL 22

Expert Comment

by:cj_1969
ID: 24474699
I thought isolation mode was on a per server/site basis ... or is the client hosting multiple sites under one server/site using host headers or something.
0
 

Author Comment

by:andculture
ID: 24474747
Unfortunately isolation mode is per server, not per site.

http://msdn.microsoft.com/en-us/library/ms524990.aspx

"IIS 6.0 cannot run both application isolation modes simultaneously. Therefore, it is not possible to run some Web applications in worker process isolation mode and others in IIS 5.0 isolation mode on the same IIS 6.0 server. If you have applications that require separate modes, you must run them on separate computers."
0
 
LVL 1

Expert Comment

by:jbeallva
ID: 24900439
This question was answered, although the answer isn't the one that the submitter wanted, I'm sure.  I answered in my my post at 05/22/09 11:24 AM, ID: 24453786.

The answer is, "this is by design."  IIS 6 and 7 will not let you process POST data in a 404 handler.

While not the answer that the submitter was looking for, it is valid information that may help someone else in a similar situation--better to know that something works a certain way (even if it's not the way you want) than waste time trying to accomplish something that will not work.
0
 
LVL 1

Expert Comment

by:jbeallva
ID: 24904874
Comments  24453786 and 24474595 address this issue.
http:#24453786
http:#24474595
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question