开发者

Session variable for particular page/url

开发者 https://www.devze.com 2023-02-08 01:23 出处:网络
I am using ASP.NET.......... It is 开发者_JAVA技巧possible to create a session variable on page load just for a particular page/url?

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

It is 开发者_JAVA技巧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!


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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消