Is there anyway to treat ViewState the same as SessionState?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
Alvin,

Absolutely amazing. I didn't expect to get a reply but this capability is
well beyond my expectations.

Thanks Mike

Alvin Bruney said:
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

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
mterzich said:
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.
 
:-)

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
mterzich said:
Alvin,

Absolutely amazing. I didn't expect to get a reply but this capability is
well beyond my expectations.

Thanks Mike

Alvin Bruney said:
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

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
mterzich said:
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.
 
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?
 
them to. I use tabbed browsing, and regularly have multiple pages open on
the same web site simultaneously.
out of curiousity, what is tabbed browsing?
 
Tabbed browsing is something supported by certain web browsers. (E.g.,
Firefox, Safari, or certain extensions for Internet Explorer.) It's where a
single window can have multiple web pages open simultaneously.

The usual UI for this has a tab control as the main UI area, and each tab
can show one web page. Here are a couple of descriptions, the second one
has a screenshot:

http://www.apple.com/safari/
http://www.mozilla.org/products/firefox/tabbed-browsing.html

I use this to keep related sets of web pages open in one window. I tend to
have four or five web browser windows open at any one time, but many of
these have three or four tabs open inside them. I find it really helpful to
be able to keep all of my related browser windows grouped together, and
since the Windows task bar doesn't provide any custom grouping facility,
tabbed browsing is a useful way of doing this.


--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

Alvin Bruney said:
them to. I use tabbed browsing, and regularly have multiple pages open
on the same web site simultaneously.
out of curiousity, what is tabbed browsing?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Ian Griffiths said:
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?
 
very, very neat!

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Ian Griffiths said:
Tabbed browsing is something supported by certain web browsers. (E.g.,
Firefox, Safari, or certain extensions for Internet Explorer.) It's where
a single window can have multiple web pages open simultaneously.

The usual UI for this has a tab control as the main UI area, and each tab
can show one web page. Here are a couple of descriptions, the second one
has a screenshot:

http://www.apple.com/safari/
http://www.mozilla.org/products/firefox/tabbed-browsing.html

I use this to keep related sets of web pages open in one window. I tend
to have four or five web browser windows open at any one time, but many of
these have three or four tabs open inside them. I find it really helpful
to be able to keep all of my related browser windows grouped together, and
since the Windows task bar doesn't provide any custom grouping facility,
tabbed browsing is a useful way of doing this.


--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

Alvin Bruney said:
them to. I use tabbed browsing, and regularly have multiple pages open
on the same web site simultaneously.
out of curiousity, what is tabbed browsing?

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
Ian Griffiths said:
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/

:
Absolutely amazing. I didn't expect to get a reply but this capability
is
well beyond my expectations.

Thanks Mike

:

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

:
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.
 
Back
Top