ViewState vs Session

G

Guest

Hi

I am aware of the technical differences.But would like to get it
clarified.Given an oppurtunity is ViewState storage more efficient than
Session based.I do not have a scenario where I need to share information
across pages but have lots of information to cache for that page.Can you
please advise which is the efficient way to do it.The page is a search
function which has a minimum of 10000 visitors per day.

Regards
Vishwanathan
 
H

Hans Kesting

Vishwanathan said:
Hi

I am aware of the technical differences.But would like to get it
clarified.Given an oppurtunity is ViewState storage more efficient
than Session based.I do not have a scenario where I need to share
information across pages but have lots of information to cache for
that page.Can you please advise which is the efficient way to do
it.The page is a search function which has a minimum of 10000
visitors per day.

Regards
Vishwanathan

The viewstate data will be sent twice over the internet (from server
to browser, and back), so you will want to keep that as small
as possible. Plus, viewstate will only work in postback-scenarios,
you will lose it if you redirect or you supply the user with a regular
link to some page of yours (but this might be exactly what you want)

On the other hand, if you store lots of data for lots of sessions,
you need a lot of memory on your server. Plus session-state
management itself costs some time on the server.

I don't think it is possible to give a hard formula whether to use
viewstate or sessionstate, but if you really don't need sessions,
you might investigate a session-less site (<sessionState mode="off"/>
in web.config) using viewstate to keep some state.

Hans Kesting
 
J

Josh

I've found that the serialisation costs of some objects going into and
coming out of viewstate can be horrendous. So if the data is in a bespoke
class you might want to test this.

I did not have the same problem when stuffing strings into the viewstate
 
K

Karl Seguin

Of course, if there's a lot of data and you can't use in memory sessions,
you'll need to serialize it to state server or SQL Server...

Karl
 
G

Guest

Hi Vishwa,
The ViewState is used to maintain the state with the page postbacks.
The Session is used to maintain the state across your whole session.
Are you using different aspx pages for search functionality or a single
page. Either way both state is efficient, you can go for page level caching
with VaryByParams.

Thanks,
Ragu.
 
K

Kevin Spencer

If you are aware of the technical differences, why are you asking the
question? The answer should be obvious.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
W

Wilbur Slice

If you are aware of the technical differences, why are you asking the
question? The answer should be obvious.


Wow. I also just read another message from Kevin a few minutes ago in
a different thread where he said, in response to a legitimate
question:

"Well, you're probably not going to like this one, but I would suggest
learning something about what you're doing, rather than just doing
it."

I said some nice things about MVP's in a thread a while ago where that
guy rhat was ragging on MVP's to get a "J.O.B." - I may have to take
some of them back...

Whatsamatter, Kevin, get up on the wrong side of the bed today? Wife
leave you? IRS audit? What?
 
K

Kevin Spencer

Whatsamatter, Kevin, get up on the wrong side of the bed today? Wife
leave you? IRS audit? What?

Not at all. Programming is a serious discipline, and an exact science. It
requires much and continuous study and hard work to be successful at. There
are no short-cuts. The first poster obviously had no idea what ASP was (was
talking about "on Normal HTML tags, I can do the following"), and was now
attempting to delve into the complex object-oriented real-word programming
discipline of ASP.Nedt. I told him what he needed to hear, that one should
not fool around with such technologies, but should undertake the discipline
and work necessary to be successful in them.

The second person began by stating that he knew the "technical differences"
between Session and ViewState. In order to know the technical differences
between them, one must know the technical details of each. If that is so,
one knows which one to use, when to use it, and how to use it. I'm not sure
what he was trying to imply, but it was unnecessary and false. Since
programming involves a relentless logic, I used logic to illustrate the
point.

Now I realize that telling people the hard truths of life is not a pleasant
task, but as my Uncle Chutney sez, "if the truth hurts, wear it." What this
means is that the sweetest of lies is more bitter than the most bitter of
truths. Somebody has to care more about the person they are communicating
with than their own reputation and/or comfort level, and be willing to
endure scorn and criticism for doing so. How can one claim to be helpful if
one is not willing to give the bitter medicine that heals, rather than the
tasty placebo that allows the patient to continue in sickness, while loving
the doctor who has given them a clean bill of health?

If you read the majority of my messages, you will see that I bend over
backwards to help those who are at all willing to help themselves. Since
your question is not of a confrontational and accusatory nature, that
includes yourself, and your question! I hope that my explanation has been
satisfactory in doing so.

And now, back to my diet of locusts and wild honey.....

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
K

Kris

Kevin said:
Not at all. Programming is a serious discipline, and an exact science. It
requires much and continuous study and hard work to be successful at. There
are no short-cuts. The first poster obviously had no idea what ASP was (was
talking about "on Normal HTML tags, I can do the following"), and was now
attempting to delve into the complex object-oriented real-word programming
discipline of ASP.Nedt. I told him what he needed to hear, that one should
not fool around with such technologies, but should undertake the discipline
and work necessary to be successful in them.

The second person began by stating that he knew the "technical differences"
between Session and ViewState. In order to know the technical differences
between them, one must know the technical details of each. If that is so,
one knows which one to use, when to use it, and how to use it. I'm not sure
what he was trying to imply, but it was unnecessary and false. Since
programming involves a relentless logic, I used logic to illustrate the
point.

Now I realize that telling people the hard truths of life is not a pleasant
task, but as my Uncle Chutney sez, "if the truth hurts, wear it." What this
means is that the sweetest of lies is more bitter than the most bitter of
truths. Somebody has to care more about the person they are communicating
with than their own reputation and/or comfort level, and be willing to
endure scorn and criticism for doing so. How can one claim to be helpful if
one is not willing to give the bitter medicine that heals, rather than the
tasty placebo that allows the patient to continue in sickness, while loving
the doctor who has given them a clean bill of health?

If you read the majority of my messages, you will see that I bend over
backwards to help those who are at all willing to help themselves. Since
your question is not of a confrontational and accusatory nature, that
includes yourself, and your question! I hope that my explanation has been
satisfactory in doing so.

And now, back to my diet of locusts and wild honey.....
Oh what a snob! So much for being a MVP.
 
J

Josh

Not at all. Programming is a serious discipline, and an exact science.

Wrong dude. Its creative, inventive and is a progressing art.
It requires much and continuous study and hard work to be successful at.

Dead Right.

There are no short-cuts. The first poster obviously had no idea what ASP
was (was talking about "on Normal HTML tags, I can do the following"), and
was now attempting to delve into the complex object-oriented real-word
programming discipline of ASP.Nedt. I told him what he needed to hear, that
one should not fool around with such technologies, but should undertake the
discipline and work necessary to be successful in them.

Your presumption is wrong. he asked about Efficiency, which incidentally is
not straightforward, and you ignored it.
The second person began by stating that he knew the "technical
differences" between Session and ViewState. In order to know the technical
differences between them, one must know the technical details of each. If
that is so, one knows which one to use, when to use it, and how to use it.
I'm not sure what he was trying to imply, but it was unnecessary and
false. Since programming involves a relentless logic, I used logic to
illustrate the point.

You never went beyond "rude". By your logic, the existance of these groups
serve no useful purpose. therefore you are here for no useful purpose. Eh?
Now I realize that telling people the hard truths of life is not a
pleasant task, but as my Uncle Chutney sez, "if the truth hurts, wear it."

He obviously left out the bit about showing human compassion.
What this means is that the sweetest of lies is more bitter than the most
bitter of truths. Somebody has to care more about the person they are
communicating with than their own reputation and/or comfort level, and be
willing to endure scorn and criticism for doing so. How can one claim to be
helpful if one is not willing to give the bitter medicine that heals,
rather than the tasty placebo that allows the patient to continue in
sickness, while loving the doctor who has given them a clean bill of
health?

.... but if someone has bad BO, do you simply say. "You stink get a bath!"
or do you ask like a decent person. the latter I hope.

If you read the majority of my messages, you will see that I bend over
backwards to help those who are at all willing to help themselves. Since
your question is not of a confrontational and accusatory nature, that
includes yourself, and your question! I hope that my explanation has been
satisfactory in doing so.

Self justification of rudeness is meerly an exercise in Ego support.
And now, back to my diet of locusts and wild honey.....

Are you a Baptist?
 
K

Kevin Spencer

Since your reply was as rude as you accuse me of being, I'll take it for
what it's worth.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
K

Kevin Spencer

Oh what a snob! So much for being a MVP.

Hey, I may be arrogant, but I come by it honestly!

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
W

Wilbur Slice

Not at all. Programming is a serious discipline, and an exact science.

Uhhh... no it's not. I suppose it *can* be, under certain
circumstances. Like, maybe writing the code that runs the Space
Shuttle or controls a heart defibrillator. But 95% of the time it's
more of an art form, and is often not serious at all.

It
requires much and continuous study and hard work to be successful at.

Speak for yourself. It's okay that you find it so difficult, but some
of us don't. Sure, there's a lot to know, and there's always more to
learn, but I think you're over-dramatizing the "hard work" and
"continuous study". I find it to be a lighter endeavor than that, and
I've been successful at it for almost 30 years now.
There
are no short-cuts.

Sure there are. Lots of them. Usenet newsgroups, for example.
The first poster obviously had no idea what ASP was (was
talking about "on Normal HTML tags, I can do the following"),

I realize that you didn't understand what he meant. But I did.
and was now
attempting to delve into the complex object-oriented real-word programming
discipline of ASP.Nedt.

There's that over-dramtization again. Lighten up.
I told him what he needed to hear, that one should
not fool around with such technologies, but should undertake the discipline
and work necessary to be successful in them.

Utter nonsense. I say - welcome to all who want to try programming,
in any language and using any tools. More power to them. Let them
indulge in it very seriously, or frivolously or anywhere in between.
For fun, or for profit. For a hobby, of for a career. Whatever.

And I thought MVP's were supposed to be here to help.

The second person began by stating that he knew the "technical differences"
between Session and ViewState. In order to know the technical differences
between them, one must know the technical details of each. If that is so,
one knows which one to use, when to use it, and how to use it. I'm not sure
what he was trying to imply, but it was unnecessary and false. Since
programming involves a relentless logic, I used logic to illustrate the
point.


<yawn> Jeeze... lighten up. All you really did was snap out a
cranky and discouraging snide posting.

Now I realize that telling people the hard truths of life is not a pleasant
task, but as my Uncle Chutney sez, "if the truth hurts, wear it." What this
means is that the sweetest of lies is more bitter than the most bitter of
truths. Somebody has to care more about the person they are communicating
with than their own reputation and/or comfort level, and be willing to
endure scorn and criticism for doing so. How can one claim to be helpful if
one is not willing to give the bitter medicine that heals, rather than the
tasty placebo that allows the patient to continue in sickness, while loving
the doctor who has given them a clean bill of health?

Jeeeeeze....



If you read the majority of my messages, you will see that I bend over
backwards to help those who are at all willing to help themselves. Since
your question is not of a confrontational and accusatory nature, that
includes yourself, and your question! I hope that my explanation has been
satisfactory in doing so.

No. Not satisfacory at all. I still think your cranky diatribes were
uncalled for and unnecessarily discouraging. And I think they were
unbecoming of an MVP. If you have nothing helpful to say, then why
not just let it pass and remain silent. Maybe someone else could
actually *help* the person looking for a little aid.
 
M

Mark Broadbent

Alright guys, I think this thread has out-lived it's usefulness. It's become
rather one sided too now. Personally I don't think (in fact I'm sure) Kevin
didn't mean to offend, although granted, on this occasion his comments were
about as helpful to the OP as all your subsequent ones AND this one! And we
all say things that are sometimes misinterpreted.

So unless anyone's got anything else constructive for Vishwanathan, lets
call it a day?

Please :)
 
K

Kevin Spencer

Welll, Wilbur, not only are you entitled to your opinion, as am I, but as we
all know, everybody has one. Apparently you think yours is better-smelling
than mine.

Personally, from working with other developers over quite a number of years,
and after having had to clean up after entirely too many of them, who manage
to make something "work" (sort of) long enough to move on to something else,
get fired, or laterally-promoted, and being a lover of the art/science of
programming, I suppose I have become a bit cranky. But perhaps you're just a
hobbyist who works all by himself, just for the fun of it, and you haven't
experienced the nightmarish scenarios that I have. Perhaps you're not paid
for your work, or simply don't feel any responsibility to your employer, who
has to pay for all the extra work hours cause by lazy, inept, or unethical
developers whose work has to be re-done by competent and diligent
developers, who take twice as long to rewrite the software, partially
because the original is such a tangled mess of disorder and chaos.

But I just can't live with myself if I waste someone else's money, and I
don't believe that anyone should. Underneath it all, programming is
mathematical in nature, and math hates inelegance. So do I. So sue me. I'm
used to it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
G

George

I stand behind you Kevin :)


The most annoying people is those who does not want to spend 30 minutes of their time to educate themselves and would rather spend our time by asking a question to forget the answer next day.

But usually i do not bother to answer those questions.

George.


Kevin Spencer said:
Oh what a snob! So much for being a MVP.

Hey, I may be arrogant, but I come by it honestly!

--
;-),

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.
 
M

Mark Broadbent

Forgive the butt kissing, but for whats it is worth I agree with everything
you have just said, but don't let the others know cos they'll probably give
me a mauling too.
Oh what the heck ....I don't care!
 
K

Kevin Spencer

Thank you, Mark!

An interesting side note: I just had my morning chat with our CTO, who was
here until 10:00 PM last night, fixing some code that was left behind by an
erstwhile developer. He told me that he had such trouble figuring it out
that he sent a copy to AMX, and that when he got on the phone with their
support guy, the support guy "laughed in my ear for 5 minutes." Of course,
he didn't think it was so funny. The poor fellow is badly in need of a
vacation!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
W

Wilbur Slice

Welll, Wilbur, not only are you entitled to your opinion, as am I, but as we
all know, everybody has one. Apparently you think yours is better-smelling
than mine.

Personally, from working with other developers over quite a number of years,
and after having had to clean up after entirely too many of them, who manage
to make something "work" (sort of) long enough to move on to something else,
get fired, or laterally-promoted, and being a lover of the art/science of
programming, I suppose I have become a bit cranky. But perhaps you're just a
hobbyist who works all by himself, just for the fun of it, and you haven't
experienced the nightmarish scenarios that I have. Perhaps you're not paid
for your work, or simply don't feel any responsibility to your employer, who
has to pay for all the extra work hours cause by lazy, inept, or unethical
developers whose work has to be re-done by competent and diligent
developers, who take twice as long to rewrite the software, partially
because the original is such a tangled mess of disorder and chaos.

But I just can't live with myself if I waste someone else's money, and I
don't believe that anyone should. Underneath it all, programming is
mathematical in nature, and math hates inelegance. So do I. So sue me. I'm
used to it.


Wow. You sound like a very ethical programmer, always scrupulously
doing the Right Thing by your employers. They must love you.

I've been programming and designing software profressionally (my only
source of income) for almost 30 years.

And I have NEVER been sued. I've never had to get "used to it."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top