Way around ASP.NET session being shared across multiple tab windows

后端 未结 6 683
半阙折子戏
半阙折子戏 2020-12-09 17:17

I\'m storing some value in an asp.net session on the first page. On the next page, this session value is being read. However if multiple tabs are opened and there are multip

6条回答
  •  天命终不由人
    2020-12-09 18:12

    It sounds like you want each page to keep it's own values, separate from each other.

    • If you can use Post (eg: you can keep from manipulating the URL on the client), hidden input tags can do the job well. You'll certainly want to encapsulate this, since doing it manually would be a huge pain. Otherwise:
    • If you're using ViewState, you could use that. Otherwise:
    • You get the values or an ID (which would be better. see below) into the URL. A last resort, because the human will be able to screw this up. Or they might bookmark it and cause confusion when they come back a week later.

    If the values cannot be sent to the client, then you need to pass a "PageSessionID" or something down to the client. This ID is either a guid (better if security is an issue) or some value you get in a way to guarantee uniqueness. Send to the client in a hidden input tag or in ViewState (or url if no other choice), and store related data on the server based on that ID.

    Cookies won't work for you purposes.

提交回复
热议问题