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.
我在.NET 3.5中构建了一个自定义404 CMS系统,虽然发布数据在IIS 5.1和6.0中本地工作,但它在生产IIS 6.0服务器上不起作用。我逐项比较了IIS 6.0站点设置,它们几乎相同,唯一的区别无关紧要。
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:
我验证了表格在每种情况下都发布到“http://domain/folder/folder/page.resource”(代码在SVN中),并且在提交时没有重定向(我抛出异常以确保) 。服务器的一些调试信息:
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:
有没有人有任何想法?我已经阅读过有关POST数据未在IIS 7.0中为404页面提交但未在6.0中提交的内容。我的表格采用以下格式:
<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.
仅对于IIS 5.1,我在“IIS>网站>属性>主目录选项卡>配置按钮>添加”中设置.resource扩展名以使用GET,HEAD和POST。这可以防止我在提交时出现405错误。
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.
编辑:我将POST更改为GET,并且在所有3种情况下它都正确地提交了数据,因此它不是表单问题。不幸的是,我无法在查询字符串中传递变量(有109个)。
2 个解决方案
#1
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.
在这里阅读更多内容:好的,我尝试发布问题描述的链接,但它说“新用户无法发布链接”。相反,我能做的最好的就是:谷歌搜索“IIS 6:在404/405自定义错误处理程序中缺少表单发布数据”(确保它在引号中),至少在我写这篇文章的时候,最重要的结果应该是我所指的页面。
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.
1)您不存在的URL被POST(例如,mydomain.com/somepage)2)IIS收到请求,注意某些页面不存在,然后它会向您的错误处理程序发出第二个请求,并且该请求的方法是内部GET。并且没有传递任何POST数据。
That leaves the question as to why you are every having success on IIS 6--that has me baffled.
这就留下了为什么你们每个人都在IIS 6上取得成功的问题 - 让我感到困惑。
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.
顺便说一句,我在IIS 6 / Windows2003上运行PHP,我发现了一个有趣的解决方法。虽然PHP没有从IIS接收POST变量(正如您所期望的那样),但PHP仍然可以访问由“php:// input”标识的原始输入流,它可以从中读取原始请求主体。这将包含原始格式的POST变量 - 我能够使用PHP的parse_str()函数从该原始字符串中获取POST变量。
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?
因此,在ASP.NET中可能会做类似的事情。您是否尝试过检查Request.InputStream?如果我的记忆正确地为我服务,那将为您提供一个可以阅读的信息流。也许它会有原始的POST数据?
-Josh
#2
Try temporarily changing the form method to GET. This should tell you if any data is being sent and what data is being sent.
尝试暂时将表单方法更改为GET。这应该告诉您是否正在发送任何数据以及正在发送什么数据。
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.
我之前遇到过类似的问题,最终导致生成发送内容的脚本出现问题,而不是数据发送时。
#1
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.
在这里阅读更多内容:好的,我尝试发布问题描述的链接,但它说“新用户无法发布链接”。相反,我能做的最好的就是:谷歌搜索“IIS 6:在404/405自定义错误处理程序中缺少表单发布数据”(确保它在引号中),至少在我写这篇文章的时候,最重要的结果应该是我所指的页面。
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.
1)您不存在的URL被POST(例如,mydomain.com/somepage)2)IIS收到请求,注意某些页面不存在,然后它会向您的错误处理程序发出第二个请求,并且该请求的方法是内部GET。并且没有传递任何POST数据。
That leaves the question as to why you are every having success on IIS 6--that has me baffled.
这就留下了为什么你们每个人都在IIS 6上取得成功的问题 - 让我感到困惑。
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.
顺便说一句,我在IIS 6 / Windows2003上运行PHP,我发现了一个有趣的解决方法。虽然PHP没有从IIS接收POST变量(正如您所期望的那样),但PHP仍然可以访问由“php:// input”标识的原始输入流,它可以从中读取原始请求主体。这将包含原始格式的POST变量 - 我能够使用PHP的parse_str()函数从该原始字符串中获取POST变量。
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?
因此,在ASP.NET中可能会做类似的事情。您是否尝试过检查Request.InputStream?如果我的记忆正确地为我服务,那将为您提供一个可以阅读的信息流。也许它会有原始的POST数据?
-Josh
#2
Try temporarily changing the form method to GET. This should tell you if any data is being sent and what data is being sent.
尝试暂时将表单方法更改为GET。这应该告诉您是否正在发送任何数据以及正在发送什么数据。
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.
我之前遇到过类似的问题,最终导致生成发送内容的脚本出现问题,而不是数据发送时。