tags:

views:

47

answers:

3

I have an MVC application that times out the session after 20 minutes. I store some values for a dropdown in a Session variable. If a user allows a page to timeout and then refreshes the page, I have no values in the dropdown.

What is the best way to deal with this?

A: 

Persist the information into some form of storage e.g. a Database.

James
A: 

I assume the dropdown data is from a database. If so, you'll need to repopulate the session. I assume you are using Windows authentication - otherwise, say if you were using form-based authentication, you would also have to get the user to log in again by redirecting to a login page.

If the dropdown data is not from a database, you could store it in Web.config and update it from there.

Exactly how you deal with this depends on specifics which you haven't mentioned. For example, on some of my projects, it's been sufficient to check if the session variable exists (on every non-post access to the page) and if absent, repopulate the session with that information.

Vinay Sajip
A: 

can i know wheather its a windows application r the webbased application

in the web-based application if u r going to use the database as source to display the data in the dropdown

we give it as

DropDownList3.DataSource = Class2.details().Tables[0]; DropDownList3.DataBind();

here class2 is the class having the functionname caleed details in that we r going to have the sql query to display the data fro the datbase to the dropdown(select query).

then we will assing that dropdownlistsdata into the session

as

session["anyname"]=dropdownlist3.selecteditem.text;

then according to u we can give the timeout values in the web.config file also

Sudhakar K