当 .NET HttpModule RewritePath 调用的目标是 PHP 文件时,$_POST 数组为空
我们有一个在 IIS 6 上运行的应用程序,它使用自定义 HttpModule 来重写 url。这非常有效(我们做得很好),除非 Context.RewritePath 目标是 .php 文件。 php 文件按预期执行,但是 $_POST 集合为空,这意味着它无法访问提交到重写 URL 的任何表单。重写为 .aspx 文件时,该问题不存在,因为 Request.Form 集合没问题。
因此,我的问题有两个部分: 为什么 $_POST 集合没有被填充? 有没有办法确保重写后正确填充 .php $_POST 集合?
我没有太多可以用代码来展示的内容。很简单:
context.RewritePath(newPath);
一旦 HttpModule 确定了将请求发送到哪里。
编辑: 有趣的是,如果我在 PHP 文件中执行 var_dump(file_get_contents('php://input'));
(方法 此处描述)显示表单内容。因此数据到达了 PHP 脚本,但没有到达 $_POST 数组。
We have an application running on IIS 6 which uses a custom HttpModule to rewrite urls. This works great (well done us) except in the case where the Context.RewritePath destination is a .php file. The php file is executed as expected, however the $_POST collection is empty meaning it cannot access any forms which are submitted to rewritten urls. The problem does not exist when rewriting to .aspx files as the Request.Form collection is fine.
My question therefore has two parts:
Why is the $_POST collection not being populated?
Is there a way to ensure that the .php $_POST collection is correctly populated after a rewrite?
I don't have much to show in the way of code. There's just a simple:
context.RewritePath(newPath);
once the HttpModule has figured out where to send the request.
Edit:
Interestingly, if I do var_dump(file_get_contents('php://input'));
in the PHP file (method described here) the contents of the form is displayed. So the data is reaching the PHP script but not the $_POST array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
重定向将 POST 操作转变为 GET 操作,这意味着最初发送的所有 POST 参数都会丢失。您必须使用反向通道方法(例如会话)才能传递变量。
Redirecting turns a POST action into a GET action, which means that any POST parameters initially sent are lost. You'll have to use a backchannel method (e.g. sessions) in order to pass the variables along.