problem with expired session

G

Guest

Hi
I have some data driven pages with a datagrid set to allow paging. This is
working fine, the only problem is if a user left the browser at such page,
and after the session expired the user click on the page number again, this
will trigger a postback but some of the required session variable has been
destroyed along with the cookie (I guess), then an error of "Null Object
reference" will be thrown!!

What is the best way to prevent such error, please?!
Would it be enough to just check User.Identity.IsAuthenticated ?

TIA

--
 
C

CodeMeister

The seesion cookie will still be intact and that session Id will be added as
a new session. The original session will have been torn down by that time
and any data stored will be lost.

Typically to avoid the session timeout issue and other session issues you
may want to query the data source on each request. By setting the page index
on the data grid it will bind to the correct records. Then it would not
matter when the request is made.

Another option would be to use SQL Server session state. That way you can
set the timeout to some long period, like 8 hours, and not lose your session
state without oveloading the server.

IHTH

Jon
 
G

Guest

But I am using form authentication! Is there any way to check if the session
of an authenticated user had expired / timeout?
TIA

CodeMeister said:
The seesion cookie will still be intact and that session Id will be added as
a new session. The original session will have been torn down by that time
and any data stored will be lost.

Typically to avoid the session timeout issue and other session issues you
may want to query the data source on each request. By setting the page index
on the data grid it will bind to the correct records. Then it would not
matter when the request is made.

Another option would be to use SQL Server session state. That way you can
set the timeout to some long period, like 8 hours, and not lose your session
state without oveloading the server.

IHTH

Jon
 
D

Dominick Baier [DevelopMentor]

Hello dl,

FormsAuth and Session are 2 distinct features.

Generally - if your session expired and you try to access something from
the Session store that isn't there anymore, you run into your described problem
- you alway have to code defensively when using sessions like

if (Session["foo"] != null)
use it
else
take actions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top