开发者

Is it possible to place view state in the session?

开发者 https://www.devze.com 2023-02-10 10:07 出处:网络
(I have a feeling i\'m making a mental error thinking this is possible, because it seems too easy, but here goes)

(I have a feeling i'm making a mental error thinking this is possible, because it seems too easy, but here goes)

For my intranet web app with 20 users on slow machines, the view state is slowing开发者_C百科 down their browsers.

But the network is local and fast.

So I think to myself, why bother putting all that data on the user's browser?...Something like putting it in the database and then all the page needs to maintain is a unique key.

But then I remembered that's how session state pretty much works.

QUESTION: Am I missing something or is this really possible?


Indeed you can. Scott Mitchell article on how to do it here:

https://web.archive.org/web/20211020131036/https://www.4guysfromrolla.com/articles/011707-1.aspx

You just need to keep an eye on your user numbers - this could potentially cause you problems if numbers get large.


Although this does not directly answer your question, I would look at inspecting what elements on your page actualy need viewstate to be loaded, you can disable it a page level, buy adding in the page declaration or on a per control basis.

<%@ Page EnableViewState=”false” %>

<asp:TextBox id=”Textbox1” runat=”server” EnableViewState=”false” />

I would highly recommend reading this article, it contains some really good insight as to how viewstate works, and some of the problems it can cause.

http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspxenter link description here

0

精彩评论

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