Does viewstate expire?

前端 未结 12 1517
-上瘾入骨i
-上瘾入骨i 2020-12-06 04:40

Let\'s say you have a aspx page that does not rely on session, but does rely on viewstate for persistance between postbacks.

If a user is accessing this page, and l

相关标签:
12条回答
  • 2020-12-06 05:10

    Viewstate itself does not expire. Since it's posted back in a form, it can be reconstituted any time.

    According to MSDN: "...it is possible for view state to expire if a page is not posted back within the session expiration time". So, in a round about sort of way, it can expire if your session does, but viewstate does not directly expire. Since you're not using session state anyway, you don't have to worry about implicit expiration.

    Note that I wouldn't have said it expired. That was MS who I quoted in their own article entitled Controlling ViewState

    0 讨论(0)
  • 2020-12-06 05:11

    ViewState is kept in a hidden field on the page itself. So as long as the user has the page, he'll have the ViewState. But if your app automatically logs the user out after a certain period of time, still having the ViewState may not do him any good.

    0 讨论(0)
  • 2020-12-06 05:14

    No Viewstate doesnot expires.After redirecting to other page then value of view state lost or expire viewstate. for more detail http://www.c-sharpcorner.com/UploadFile/78d182/Asp-Net-state-management-techniques/

    0 讨论(0)
  • 2020-12-06 05:15

    Also, as a gotcha, by default ASP.NET encrypts ViewState with an autogenerated key. This can be overridden with the MachineKey element in the web.congif file. Even though ViewState won't expire, it can become invalid if a different autogenerated key is used to decrypt ViewState, such as after an IIS Reset, redeploying an application, or hitting a different server in a web farm. If you're planning on storing viewstate for long periods of time, watch out for how it's encrypted/decrypted.

    http://msdn.microsoft.com/en-us/library/ms998288.aspx

    0 讨论(0)
  • 2020-12-06 05:17

    Viewstate does not expire, as long as they are still on the page, it will still be there and functional.

    0 讨论(0)
  • 2020-12-06 05:20

    Viewstate does not expire.

    All viewstate data is stored on the client and is submitted back to the server when the user executes a postback.

    This has some very interesting implications, and is explained very thoroughly here.

    0 讨论(0)
提交回复
热议问题