问题描述
我们能否在页面的卸载事件中访问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).
[...]
在卸载阶段,页面及其控件已呈现,因此您无法对响应流进行进一步的更改.如果您尝试调用诸如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对象吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!