我们可以在页面的卸载事件中访问viewstate和session对象吗 [英] can we access viewstate and session objects at unload event of page

查看:79
本文介绍了我们可以在页面的卸载事件中访问viewstate和session对象吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们能否在页面的卸载事件中访问viewstate和session对象.

can we access viewstate and session objects at unload event of page.

推荐答案

卸载"页面响应发送到客户端浏览器后立即调用该事件,除了清除资源(即文件/数据库句柄等)之外,在此事件中通常没有任何其他作用.

The "unload" event is called as soon as the page response has been sent to the client browser, there's usually nothing useful you can do in this event, other than clear up resources (i.e. file/database handles, etc).

在页面已完全呈现,发送给客户端并准备丢弃之后,将调用Unload.此时,页面属性(如响应"和请求")将被卸载,并执行所有清除操作.

Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.

[...]

在卸载阶段,页面及其控件已呈现,因此您无法对响应流进行进一步的更改.如果您尝试调用诸如Response.Write方法之类的方法,则该页面将引发异常.(摘自 ASP.NET页面生命周期概述).

During the unload stage, the page and its controls have been rendered, so you cannot make further changes to the response stream. If you attempt to call a method such as the Response.Write method, the page will throw an exception. (From ASP.NET Page Life Cycle Overview).

您可能能够读取viewstate,您当然不能更改它,并且会话可能也是如此.您要达到什么目的?

You might possibly be able to read viewstate, you certainly can't change it, and the same propbably holds true for session. What are you trying to achieve?

这篇关于我们可以在页面的卸载事件中访问viewstate和session对象吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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