本文介绍了当我们使用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 解决方案 参考 - 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 to Response.Redirect should end the response. Calling the overload without this argument is the same as specifying true to indicate that the response should end.Ending the reponse means that Response.End is called after the response has been modified to make the redirect happen, and Response.End throws an ThreadAbortException to terminate the current module.Any code after a call to Response.Redirect is never called (unless you supply false for the extra argument). Actually, code in finally and certain catch handlers will execute, but you cannot swallow a ThreadAbortException.it take two argument Response.Redirect("~/b.aspx",true); // this will end the responseResponse.Redirect("~/b.aspx",false); // this will not end the response and will throw exception 这篇关于当我们使用Response.Redirect时,一步一步会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 20:12