Re: Is there anyway to treat ViewState the same as SessionState?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ian Griffiths [C# MVP] (ian-interact-sw_at_nospam.nospam)
Date: 11/29/04


Date: Mon, 29 Nov 2004 13:26:44 -0000

Of course you have to ask yourself what will happen when your users open
multiple pages into your application - there's nothing stopping a user
looking at more than one of your web pages at once. What will happen to
your application when this happens if you're assuming that their navigation
will be linear?

You may have disabled the back button, but that doesn't mean users will
necessarily follow the linear path through your application that you want
them to. I use tabbed browsing, and regularly have multiple pages open on
the same web site simultaneously. So although you can stop me clicking on
the Back button, what you can't stop me doing is following a link in a new
tab, navigating around in this page a bit, and then going back to the old
tab.

So while you've disabled the Back button itself, I've recreated the
functionality with tabbed browsing - I can go 'back' to an older page by the
simple expedient of leaving that page open.

Users are like this - they will find creative ways to work around it when
your application disables styles of navigation they want to use.

One of the potential benefits of using ViewState is that it doesn't actually
matter when users do this - the state is maintained by the browser for that
page. But if you move over to a model where you push this state into the
session, it's going to break if people are navigating through your site
creatively.

If you really wanted to force people to follow a linear path through the
application, you could store some kind of sequence number in both the
session state and the viewstate, and reject requests where this doesn't
match. But I wouldn't really recommend that, and for the same reason I also
wouldn't really recommend disabling the back button - why are you
constraining the user in this way? Web sites that do this always annoy me a
great deal... It's better for the user if you can avoid this sort of thing.

What are you doing that involves having a large enough viewstate that it's
causing you problems?

-- 
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/
"mterzich" wrote:
> Absolutely amazing. I didn't expect to get a reply but this capability is
> well beyond my expectations.
>
> Thanks Mike
>
> "Alvin Bruney [MVP]" wrote:
>
>> this isn't built in but you can override savepagestatetopersistencemedium
>> and loadpagefrompersistencemedium whose default is to save it to the view
>> state bag. so you can add it to session there
>>
>> "mterzich" wrote:
>> >I developed a web application that doesn't allow the Back Arrow on the
>> > browser to work (disabled cacheing, always call myself on any event, 
>> > and
>> > code
>> > in Load_Page that will redirect to the active page). Under this case I
>> > will
>> > only have the possibility of one active viewstate. Therefore the 
>> > massive
>> > amount of data being transfered back and forth in the viewstate hidden
>> > attribute just causes my performance to degredate badly without any
>> > possible
>> > benefits. Since I can only have one possible viewstate (not multiple 
>> > when
>> > the
>> > back arrow is allowed) it would be nice to have the view state treated
>> > like
>> > the session state (the easiest would be to place the view state in a
>> > Session
>> > variable that could be retrieved by the Framework anytime a post is 
>> > done).
>> >
>> > Is there such a capability built into the Framework? I checked the 
>> > @page
>> > directive and did some searches but couldn't find any such capability. 


Relevant Pages

  • Re: WebUserControls and SessionState
    ... multiple steps for each table of the dataset where each step is a different ... Do I need to use Session to keep track of the ... view of a MultiView control" ... viewstate, it will turn your page slow... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: WebUserControls and SessionState
    ... What do you mean by dont put any data thing on session? ... "multiple steps for each table of the dataset where each step is a ... view of a MultiView control" ... viewstate, it will turn your page slow... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session state and multiple windows/frames
    ... different sets of ViewState. ... session, ... > heavy use of 3rd-party controls, popup windows and frames (not my design ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Help! Serializing Viewstate Problems!?!?
    ... > and thus my viewstate was getting very large and it was slowing ... Note: All other session ... > Unable to serialize the session state. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Help! Serializing Viewstate Problems!?!?
    ... If you're using Session, why bother with ViewState at all? ... > "Kevin Spencer" wrote in message ... >>> Unable to serialize the session state. ...
    (microsoft.public.dotnet.framework.aspnet)