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

后端 未结 6 690
半阙折子戏
半阙折子戏 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

    1. Give each page a guid. Store the guid in a hidden field.
    2. Use this guid as the session key that stores a struct with all the variables etc. for that page.
    3. You can now pull information for a specific page "rendering" and passes data to the session struct to the new "rendering" in the code-behind.

    This is similar to what ViewState does automatically.

    EDIT

    Comment response

    I don't think that's possible as you described it.

    In your question you mentioned page 1 to 2 navigation. If the user types in the URL for page 2 in the browser then how do you tie that current page 2 rendering with the previous page 1?

    You need something to do so, unless the code-behind can search a list of incomplete workflows that have stopped at page 1 and uses that as the previous guid value for the new page 2 rendering.

    Comment response 2

    You can find all the links on the page and modify those but it hints that something is wrong ( in my opinion ). But...

    http://www.extremeexperts.com/Net/Articles/LoopingthroughControls.aspx

    Gives you a simple way of processing all controls on the page. You can test to see if the control is a hyperlink easily. Not that all links will need that runat="server" parameter set for this to work.

提交回复
热议问题