Cross page data: Session, Viewstate or something else?

  • Thread starter Thread starter Zaccariah Kowalsky
  • Start date Start date
Z

Zaccariah Kowalsky

Hello,

I have a webapp with on each page a "language" drop down list. Now, if I
choose X, I want to initialise the drop down list to X. Easy to understand.
But what is the best way to do this in ASP.NET? The obvious answer is, I
think, the Session object. But one thing annoys me: a session can expire. It
is difficult to guess the expiration time; 20 minutes, 40, 60? I just don't
know. Is there a better way to pass data between pages? I was thinking about
the good old url parameters: page.aspx?language=en. But I don't think that's
the ASP.NET way.

Ideas, suggestions and comments more than welcome.
 
If you are talking about small amounts of data, passing it in the URL is
fine.

It is not difficult to guess the expiration time of a session, since that is
a setting you configure
 
Marina said:
If you are talking about small amounts of data, passing it in the URL is
fine.

It is not difficult to guess the expiration time of a session, since that is
a setting you configure

It is. You never know how long a customer will stay on your site. 5 minutes
or 2 hours?
 
The session timer is reset each time a user request a
page, so it is perfectly normal to keep your currently
selected language in the session. The session expires if
the user doesn't request a page for longer than X minutes
where X is your session timeout period which is by default
set to 20 minutes.

You could keep the language in the viewstate but it will
not be easily accessible from nested child controls and
such. Since the selected language is more of a global
variable that all pages and controls probably use the
Session is the best way to keep it.
 
Back
Top