是response.redirect总是一个http GET响应? [英] is response.redirect always an http GET response?
问题描述
是response.redirect总是一个http GET响应?或者它可能是POST?....
在大多数API中,标准重定向实现确实是每个定义得到。根据您熟悉的ASP.NET问题历史,我将为Java Servlet添加示例。
ASP.NET:
Response.Redirect(http://google.com);
Servlet:
response.sendRedirect是( http://google.com);
它隐式设置响应状态为302, 当 current 请求是一个POST请求并且您想要使用POST重定向时,那么您需要307重定向。这不是由标准API提供的,但它通常只是设置适当的响应状态和标题。 ASP.NET: Servlet: 请注意,这将在请求最终用户确认的平均客户端上发出安全/确认警告发送POST数据到另一个位置。 is response.redirect always an http GET response? or it could be POST?.... In most API's the standard redirect implementation does a 302 which is indeed per definition GET. As per your question history you're familiar with ASP.NET, I'll however add examples for Java Servlets as well. ASP.NET: Servlet: It implicitly sets the response status to 302 and the When the current request is a POST request and you want to redirect with POST, then you need a 307 redirect. This is not provided by the standard API, but it's usually just a matter of setting the appropriate response status and header. ASP.NET: Servlet: Note that this will issue a security/confirmation warning on the average client which requests the enduser for confirmation to send the POST data to another location. 这篇关于是response.redirect总是一个http GET响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
Response.Status =307临时重定向;
Response.AddHeader(Location,http://google.com);
response.setStatus(307);
response.setHeader(Location,http://google.com);
Response.Redirect("http://google.com");
response.sendRedirect("http://google.com");
Location
header to the given URL.Response.Status = "307 Temporary Redirect";
Response.AddHeader("Location", "http://google.com");
response.setStatus(307);
response.setHeader("Location", "http://google.com");