使用IE(而不是FF)时,ViewState的问题仍然存在于会话中 [英] problem with ViewState persisted to session when using IE (but not FF)

查看:76
本文介绍了使用IE(而不是FF)时,ViewState的问题仍然存在于会话中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VB.Net网站,在我的注册页面上,我将ViewState存储在Session中.我正在使用以下代码来实现这一目标.

I have a VB.Net web site and on my sign up page I am storing the ViewState in Session. I am using the following code to achieve this.

Private _sessionViewStatePersister As System.Web.UI.PageStatePersister
Protected Overrides ReadOnly Property PageStatePersister() As System.Web.UI.PageStatePersister
    Get
        If _sessionViewStatePersister Is Nothing Then
            _sessionViewStatePersister = New SessionPageStatePersister(Me)
        End If
        Return _sessionViewStatePersister
    End Get
End Property

这已经工作了好几个月了,然后我开始偶尔看到"System.NullReferenceException:对象引用未设置为对象的实例."

This has been working fine for months, then I started seeing the occasional 'System.NullReferenceException: Object reference not set to an instance of an object.'.

当我尝试从DropDownList的SelectedItem获取Text属性的值时,引发了异常,问题是DropDownList在页面回发后不包含任何项.

The exception is raised when I try to get the value of the Text Property from the SelectedItem of a DropDownList, the problem being the DropDownList does not contain items after the page has posted back.

该问题仅在使用IE(根据我的日志显示为7或8,但我仅使用8进行测试)时出现,而在使用FireFox 3.5时则不存在.

The problem is only present when using IE (7 or 8 according to my logs, but I have only tested with 8), but not when using FireFox 3.5.

恢复使用常规的ViewState持久性机制导致该页面再次在IE中工作.没有记录与ViewState相关的异常,就像页面只是认为"它没有存储ViewState一样.

Reverting to using the normal ViewState persistence mechanism caused the page to work in IE again. There are no ViewState related exceptions logged, it is like the page just 'thinks' it has no stored ViewState.

有人知道这是什么原因造成的,最近是否有IE补丁可能是罪魁祸首?其他人有没有经历过我所描述的经历?

Does anyone know what might have caused this, have there been any recent patches to IE that might be the culprit? Has anyone else experienced anything like what I have described?

谢谢!

推荐答案

您是否正在使用无cookie会话?如果没有...

Are you using cookieless Session? If not...

默认情况下,会话状态要求在客户端浏览器上启用cookie.如果您将ViewState存储在Session中,则意味着ViewState页面现在依赖于cookie ...因此可以在客户端禁用它,从而破坏您的应用程序.

By default, Session state requires cookies to be enabled on the client browser. If you are storing ViewState in Session, that means page ViewState is now dependent on cookies... and hence, can be disabled at the client side, breaking your app.

仅在IE浏览器中发生的事实可能仅仅是巧合吗?

The fact it's only happened with IE browsers may be mere coincidence?

这篇关于使用IE(而不是FF)时,ViewState的问题仍然存在于会话中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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