当我们使用Response.Redirect时,一步一步会发生什么? [英] What happens step by step when we use Response.Redirect?
问题描述
问题不在于使用Response.Redirect的功能有多少而是查询 -
1.当我们使用Response.Redirect时,浏览器和服务器一步一步发生什么?
2.当我们使用Response时。重定向从浏览器传递到服务器的信息。如果我重新构建问题,我有一个源页面a.aspx和目标页面b.aspx ..当我们从a.aspx调用Response.Redirect时,传递给服务器的信息是什么?
3.我有一行代码如下:
Response.Redirect(〜/ b.aspx);
int i = 10;
如果我们调试代码并且Response.Redirect成功执行,光标是否会转到第二行?
谢谢
Supratik
< blockquote>参考 - HttpResponse.Redirect Method(String,Boolean) [ ^ ]和 ASP.NET:Response.Redirect(...)之后代码会发生什么变化? [ ^ ]
Quote:
Response.Redirect
有一个重载,接受一个布尔参数,指示对Response.Redirect
的调用是否应该结束响应。在没有此参数的情况下调用重载与指定true
相同,以指示响应应该结束。
结束响应意味着在修改响应以使重定向发生后调用Response.End
,并且Response.End
抛出一个ThreadAbortException
来终止当前模块。
调用从不调用Response.Redirect
(除非您为额外参数提供false
)。实际上,finally
中的代码和某些catch
处理程序将会执行,但你不能吞下ThreadAbortException
。
它需要两个参数
Response.Redirect(〜/ b.aspx,真正的); //这将结束响应
Response.Redirect(〜/ b.aspx,false); //这不会结束响应并抛出异常
Hi,
The question is not about what are the features of using Response.Redirect rather the queries are -
1. What happens step by step with the browser as well as server when we use Response.Redirect?
2. When we use Response.Redirect what are the information that passes from browser to server. If I re-frame the question it is like, I have a source page a.aspx and a target page b.aspx..when we call Response.Redirect from a.aspx what are the information that passes to server?
3. I have a lines of code like the following:
Response.Redirect(~/b.aspx);
int i = 10;
Will the cursor go to the second line if we debug the code and the Response.Redirect executes successfully?
Thanks
Supratik
Refer - HttpResponse.Redirect Method (String, Boolean)[^] and ASP.NET: What happens to code after Response.Redirect(…)?[^]
Quote:
Response.Redirect
has an overload accepting a boolean argument that indicates if the call toResponse.Redirect
should end the response. Calling the overload without this argument is the same as specifyingtrue
to indicate that the response should end.
Ending the reponse means thatResponse.End
is called after the response has been modified to make the redirect happen, andResponse.End
throws anThreadAbortException
to terminate the current module.
Any code after a call toResponse.Redirect
is never called (unless you supplyfalse
for the extra argument). Actually, code infinally
and certaincatch
handlers will execute, but you cannot swallow aThreadAbortException
.
it take two argument
Response.Redirect("~/b.aspx",true); // this will end the response
Response.Redirect("~/b.aspx",false); // this will not end the response and will throw exception
这篇关于当我们使用Response.Redirect时,一步一步会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!