Etienne
Etienne

Reputation: 7201

Session variable for particular page/url

I am using ASP.NET..........

It is possible to create a session variable on page load just for a particular page/url?

The problem that I have is: The user comes to page 1 and the session variable becomes A, then he opens page 2 in a new tab and the session variable because B on both page 1 and page 2.

So when the user needs the session variable on page 1 it does not work because the variable have changed!

Upvotes: 0

Views: 1480

Answers (2)

You can have more than one session variable. Just name the one on page A Session["variableA"] and the one on page B Session["variableB"].

Or am I misunderstanding?

Upvotes: 2

marcind
marcind

Reputation: 53183

There's no way to do that. Session variables are meant for the user's whole session. If you want to store page-specific information you need to round trip it between the server and the client on every request, for example by using the page's ViewState.

Tabbed browsing is a widespread feature these days and you have to design your sites so that they work correctly even if the user keeps switching tabs when interacting with your site.

Upvotes: 1

Related Questions