问题描述
据我所知,我们可以用两种方法来重定向HTTP响应。
As far as I know, we can use two method to redirects http response.
- 使用Java脚本window.location的;
- 在ASP.Net使用HttpContext.Current.Response.Redirect
从功能和最终用户的角度来看,有两种方法可以互换?
From function and end user perspective, are the two methods interchangeable?
推荐答案
window.location的
既需要的JavaScript和浏览器下载并呈现原始页面的内容(包括CSS /脚本)的页面被更改之前首先
window.location
requires both javascript and for the browser to download and render the original page's contents (including css/scripts) first before the page is changed.
,在另一方面,发出302状态code。与Location头。这将导致浏览器,而无需下载/绘制原第一马上请求下一个页面。
Response.Redirect
, on the other hand, issues a 302 status code with a Location header. This causes the browser to instantly request the next page without downloading/rendering the original first.
href=\"http://stackoverflow.com/questions/1163544/javascript-window-parent-issue\">等问题,这是值得注意的是,窗口.location
具有能够以之前的执行其他JavaScript的效益的位置被改变。例如,改变另一帧的位置,并在同一时间的当前帧
Based on your other question, it's worth noting that window.location
has the benefit of being able to execute other javascript before the location is changed. For example, changing the location of another frame AND the current frame at the same time.
这篇关于HTTP重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!