Vb.net – problem with ViewState persisted to session when using IE (but not FF)

asp.netvb.net

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

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.'.

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.

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.

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.

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?

Thanks!

Best Answer

Are you using cookieless Session? If not...

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.

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

Related Topic