当使用Server.Transfer的是整个Asp.Net生命周期再次执行? [英] When Using Server.Transfer is the entire Asp.Net life-cycle executed again?

查看:165
本文介绍了当使用Server.Transfer的是整个Asp.Net生命周期再次执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,Server.Transfer的不来回回请求客户端。

I understand that Server.Transfer doesn't make a round trip back to the requesting client.

我一直没能学会是,如果控制简单地直接传递给你传送到或者如果整个请求生命周期再次执行新的请求处理程序。

What I haven't been able to learn is if control is simply passed directly to the new request handler you're transferring to or if or if the entire request life-cycle is executed again.

我想整个生命周期是传递URL再次执行,但想验证这一点是事实。

I assume the entire life-cycle is executed again using the transfer URL but wanted to verify this was the case.

推荐答案

下面是我通过实验发现。

Here is what I found through experimentation.

在使用 Server.Transfer的整个请求生命周期不会再跑去。

When using Server.Transfer the entire request life cycle is not ran again.

如果你写你自己的模块,把它挂到请求的生命周期,并从该模块的请求生命周期的其余部分将被跳过调用 Server.Transfer的和页面生命周期会立即开始。

If you write your own Module, hook it into the request life cycle, and call Server.Transfer from that module the rest of the request life cycle will be skipped and the page life cycle will begin immediately.

完成传输页面生命周期请求生命周期的复苏回升,其拆除的事件之后。注意,在用于拆卸的事件将是从传送的原始的HtppContext。即,URL和查询字符串值将是相同的原始请求和不适合你转移到该页的URL和查询字符串值。

After completing the transfer page life cycle the request life cycle picks back up with its tear-down events. Note, the HtppContext in for the tear-down events will be the original one you transferred from. That is, the URL and QueryString values will be the same as the original request and not be the URL and QueryString values for the page you transferred to.

Server.Transfer的并修改 HttpContext.Request 对象包含页面中新的URL和查询字符串信息生命周期为您转移到该页面。

Server.Transfer does modify the HttpContext.Request object to contain the new URL and QueryString information during the page life cycle for the page you transferred to.

如果您转移到一种资源,是不是一个网页,而是基于文本(例如something.xml)该页面的内容将被精确地返回是它的编码设置为text / html的。

If you transfer to a resource that is not a page but is text based (e.g. something.xml) the content of that page will be returned exactly as is with its encoding set to text/html.

如果您转移到资源不是一个网页,而不是基于文本(例如something.pdf),那么Htt​​pException错误将被抛出。出现这种情况,即使你定义了一个自定义处理该资源。

If you transfer to a resource that is not a page and is not text based (e.g. something.pdf) then an HttpException error will be thrown. This happens even if you have defined a custom Handler for this resource.

这篇关于当使用Server.Transfer的是整个Asp.Net生命周期再次执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆