Viewstate expires

Viewstate expires

am 31.01.2008 15:54:02 von ChrisDavoli

I wqas told to put a machine key into the web config so it would do the
encryption the same. I did that and I still get the following error. Any
other suggestions?

I store some stuff in view state and then if I leave the browser instance
alone say for 20 minutes, it gives me this message when I go to retrieve from
viewstate. Before it expires it works perfectly. Is there anything I can do
to not have it expire? Or what is it doing?

IT HIGHLIGHTS IN RED LINE 334

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:


Line 332: End If
Line 333:
Line 334: If
ViewState("SpecialInstructions").ToString.Trim.Length > 0 Then
Line 335: lblSpecialInstructions.Text =
ViewState("SpecialInstructions").ToString
Line 336: pnlSpecialInstructions.Visible = True


--
Chris Davoli

RE: Viewstate expires

am 31.01.2008 17:35:01 von brucebarker

are you checking IsPostback before accessing viewstate for saved values?

most likely you have redirect logic on expired session or authentication,
and the page request is a get (no viewstate passed).


-- bruce (sqlwork.com)


"Chris Davoli" wrote:

> I wqas told to put a machine key into the web config so it would do the
> encryption the same. I did that and I still get the following error. Any
> other suggestions?
>
> I store some stuff in view state and then if I leave the browser instance
> alone say for 20 minutes, it gives me this message when I go to retrieve from
> viewstate. Before it expires it works perfectly. Is there anything I can do
> to not have it expire? Or what is it doing?
>
> IT HIGHLIGHTS IN RED LINE 334
>
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
>
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
> Source Error:
>
>
> Line 332: End If
> Line 333:
> Line 334: If
> ViewState("SpecialInstructions").ToString.Trim.Length > 0 Then
> Line 335: lblSpecialInstructions.Text =
> ViewState("SpecialInstructions").ToString
> Line 336: pnlSpecialInstructions.Visible = True
>
>
> --
> Chris Davoli
>