Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computer Certification > MCSD > Why ViewState doesn't work in ASP.NET?

Reply
Thread Tools

Why ViewState doesn't work in ASP.NET?

 
 
jacksu
Guest
Posts: n/a
 
      02-20-2004
I set the viewstate in page_load, and try to get it in the
click function. But it shows NullPointException.

Does ViewState only within one request? or can it go
through session?

Thanks.

Jack
 
Reply With Quote
 
 
 
 
Hayato Iriumi
Guest
Posts: n/a
 
      02-20-2004
ViewState is good for each PostBack. If you don't postback, it goes away.
After all, ViewState is data in hidden field.

"jacksu" <> wrote in message
news:12fe601c3f7b7$b0721c10$...
> I set the viewstate in page_load, and try to get it in the
> click function. But it shows NullPointException.
>
> Does ViewState only within one request? or can it go
> through session?
>
> Thanks.
>
> Jack



 
Reply With Quote
 
 
 
 
The Poster Formerly Known as Kline Sphere
Guest
Posts: n/a
 
      02-21-2004
>After all, ViewState is data in hidden field.
.... and nothing more than that.

Kline Sphere (Chalk) MCNGP #3
 
Reply With Quote
 
Brunswick Lowe
Guest
Posts: n/a
 
      02-21-2004
It's encrypted, though, right?


"The Poster Formerly Known as Kline Sphere" <.> wrote in message
news:...
> >After all, ViewState is data in hidden field.

> ... and nothing more than that.
>
> Kline Sphere (Chalk) MCNGP #3



 
Reply With Quote
 
The Poster Formerly Known as Kline Sphere
Guest
Posts: n/a
 
      02-21-2004
>It's encrypted, though, right?

No, just encoded.

Kline Sphere (Chalk) MCNGP #3
 
Reply With Quote
 
UAError
Guest
Posts: n/a
 
      02-22-2004
"Brunswick Lowe" <> wrote:

>It's encrypted, though, right?
>

Is only encrypted if in the machine.config:

<machineKey validation='3DES' />


Building Secure ASP.NET Applications
Chapter 8: Page 187

Securing View State

If your ASP.NET Web applications use view state:
- Ensure the integrity of view state (to ensure
it is not altered in any way while in transit)
by setting the enableViewStateMac to true as
shown below. This causes ASP.NET to generate
a Message Authentication Code (MAC) on the
page’s view state when the page is posted
back from the client.
<% @ Page enableViewStateMac=true >
- Configure the validation attribute on the
<machineKey> element in Machine.config, to
specify the type of encryption to use for data validation.
Consider the following:
- Secure Hash Algorithm 1 (SHA1) produces a larger hash
size than Message Digest 5 (MD5) so it is considered
more secure. However, view state protected with SHA1
or MD5 can be decoded in transit or on the client
side and can potentially be viewed in plain text
- Use 3 Data Encryption Standard (3DES) to detect
changes in the view state and to also encrypt it
while in transit. When in this state, even if
view state is decoded, it cannot be viewed in plain text.
 
Reply With Quote
 
The Poster Formerly Known as Kline Sphere
Guest
Posts: n/a
 
      02-22-2004
Good point.

However, any data which requires secure transmission should [also]
have been secured at the start of the conversation, as is the case
when using https. The problem with only using the viewstatemac setting
is that information (i.e. that contained in form variables) is sent as
part of the request to the server and naturally not encrypted. As
such, it is only the __VIEWSTATE field which is encrypted on the
server, which is then sent back to client as part of the response.

On Sun, 22 Feb 2004 00:35:16 -0500, UAError <> wrote:

>"Brunswick Lowe" <> wrote:
>
>>It's encrypted, though, right?
>>

>Is only encrypted if in the machine.config:
>
><machineKey validation='3DES' />
>
>
>Building Secure ASP.NET Applications
>Chapter 8: Page 187
>
>Securing View State
>
>If your ASP.NET Web applications use view state:
>- Ensure the integrity of view state (to ensure
> it is not altered in any way while in transit)
> by setting the enableViewStateMac to true as
> shown below. This causes ASP.NET to generate
> a Message Authentication Code (MAC) on the
> page’s view state when the page is posted
> back from the client.
> <% @ Page enableViewStateMac=true >
>- Configure the validation attribute on the
> <machineKey> element in Machine.config, to
> specify the type of encryption to use for data validation.
> Consider the following:
> - Secure Hash Algorithm 1 (SHA1) produces a larger hash
> size than Message Digest 5 (MD5) so it is considered
> more secure. However, view state protected with SHA1
> or MD5 can be decoded in transit or on the client
> side and can potentially be viewed in plain text
> - Use 3 Data Encryption Standard (3DES) to detect
> changes in the view state and to also encrypt it
> while in transit. When in this state, even if
> view state is decoded, it cannot be viewed in plain text.



Kline Sphere (Chalk) MCNGP #3
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why why why does function not work Horace Nunley ASP .Net 1 09-27-2006 09:52 PM
Datatable in ViewState... why does this work? cmay ASP .Net 5 07-14-2005 01:19 PM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57