【发布时间】:2011-03-08 09:32:50
【问题描述】:
我想POST 将数据发送到网络服务器的默认页面,例如:
POST http://errorreporting.example.com/ HTTP/1.1
我希望服务器负责 302 将客户端重定向到 POST 应该去的地方。服务器上的default.asp 文件通过执行Redirect 来执行此任务(which is the technique Microsoft recommends):
default.asp:
<%
Response.Redirect "SubmitError.ashx"
%>
当我简单地浏览服务器时:
GET http://errorreporting.example.com/ HTTP/1.1
我从服务器得到了预期的响应:
HTTP/1.1 302 Object moved
Server: Microsoft-IIS/5.0
Location: SubmitError.ashx
...
但是当我POST到服务器时:
POST http://errorreporting.example.com/ HTTP/1.1
服务器对我很生气:
HTTP/1.1 405 Method not allowed
Connection: close
Allow: OPTIONS, TRACE, GET, HEAD
...
我希望服务器能够将客户端重定向到适当的提交URL,而不是使用URL。当然,这是因为 URL 可能(即已经)改变了:
http://errorreporting.example.com/SubmitError.asphttp://errorreporting.example.com/SubmitError.aspxhttp://errorreporting.example.com/SubmitError.ashxhttp://errorreporting.example.com/ErrorReporting/Submit.ashxhttp://errorreporting.example.com/submiterror.phphttp://errorreporting.example.com/submit/submiterror.ashx
等等
注意:如果我将URL 更改为包含文档位置:
/* SErrorReportingUrl = 'http://www.example.com:8088/ErrorReporting/SubmitError.ashx';
SErrorReportingUrl = 'http://www.example.com/ErrorReporting/SubmitError.ashx';
SErrorReportingUrl = 'http://errorreporting.example.com:8088/ErrorReporting/SubmitError.ashx';
SErrorReportingUrl = 'http://errorreporting.example.com/SubmitError.ashx';
SErrorReportingUrl = 'http://errorreporting.example.com';
SErrorReportingUrl = 'http://errorreporting.example.com/SubmitError.ashx';
*/
SErrorReportingUrl = 'http://errorreporting.example.com/submit/SubmitError.ashx';
效果很好:
HTTP/1.1 200 OK
【问题讨论】:
标签: iis post http-status-code-405