我想将POST
数据形成网络服务器的默认页面,例如:
POST http://errorreporting.example.com/ HTTP/1.1
我希望服务器负责302
将客户端重定向到POST
应该去的地方。服务器上的default.asp
文件执行此任务(这是 Microsoft 推荐的技术),通过执行Redirect
:
默认.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.asp
http://errorreporting.example.com/SubmitError.aspx
http://errorreporting.example.com/SubmitError.ashx
http://errorreporting.example.com/ErrorReporting/Submit.ashx
http://errorreporting.example.com/submiterror.php
http://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