469,283 Members | 2,263 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

viewstate error

Hi

Users seem to be getting the following intermitent error whe they post a
form.

Validation of viewstate MAC failed. If this application is hosted by a
Web Farm or cluster, ensure that <machineKeyconfiguration specifies
the same validationKey and validation algorithm. AutoGenerate cannot be
used in a cluster.

We are not in a cluster situation. I believe it may be because there is a
delay in posting back so the viewstate is expiring. I wanted to know if there
is any way to increase the timeout of the view state, is it bound to the
session timeout (we are not using forms authentication)?

Alternatively any way to turn this viewstate check off (it is a restriced
admin site so there should be no security problems although I would prefer
just to extend the timeout)


--
Scott
Oct 11 '06 #1
6 6020
ViewState does not timeout. It is an encrypted string in your page (hidden
field). There is a setting on the @Page directive for ViewStateMac. Set it
both ways (forget which setting cures this, but a google might solve it).
The second thing to do is generate your keys. You can find machineKey
generators on the web.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"scottrm" <sc*****@newsgroup.nospamwrote in message
news:44**********************************@microsof t.com...
Hi

Users seem to be getting the following intermitent error whe they post a
form.

Validation of viewstate MAC failed. If this application is hosted by a
Web Farm or cluster, ensure that <machineKeyconfiguration specifies
the same validationKey and validation algorithm. AutoGenerate cannot be
used in a cluster.

We are not in a cluster situation. I believe it may be because there is a
delay in posting back so the viewstate is expiring. I wanted to know if
there
is any way to increase the timeout of the view state, is it bound to the
session timeout (we are not using forms authentication)?

Alternatively any way to turn this viewstate check off (it is a restriced
admin site so there should be no security problems although I would prefer
just to extend the timeout)


--
Scott

Oct 11 '06 #2
Hi

Thanks for your reply, I think I was not being that clear, I am aware view
state itself does not time out as such but according to what I read "
ASP.NET will perform a simple digest on the viewstate and check it later
when page postback, however, this digest is not valid forever"

Also would setting the key make any difference in a non-cluster environment.

Scott
--
Scott
"Cowboy (Gregory A. Beamer)" wrote:
ViewState does not timeout. It is an encrypted string in your page (hidden
field). There is a setting on the @Page directive for ViewStateMac. Set it
both ways (forget which setting cures this, but a google might solve it).
The second thing to do is generate your keys. You can find machineKey
generators on the web.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"scottrm" <sc*****@newsgroup.nospamwrote in message
news:44**********************************@microsof t.com...
Hi

Users seem to be getting the following intermitent error whe they post a
form.

Validation of viewstate MAC failed. If this application is hosted by a
Web Farm or cluster, ensure that <machineKeyconfiguration specifies
the same validationKey and validation algorithm. AutoGenerate cannot be
used in a cluster.

We are not in a cluster situation. I believe it may be because there is a
delay in posting back so the viewstate is expiring. I wanted to know if
there
is any way to increase the timeout of the view state, is it bound to the
session timeout (we are not using forms authentication)?

Alternatively any way to turn this viewstate check off (it is a restriced
admin site so there should be no security problems although I would prefer
just to extend the timeout)


--
Scott


Oct 11 '06 #3
There's a web.config key that you can set to enable or disable the ViewStateMac
setting.

In your <pagestag, add enableViewStateMac="true" or enableViewStateMac="false".

-dl

--
David Longnecker
Web Developer
http://blog.tiredstudent.com
Hi

Users seem to be getting the following intermitent error whe they post
a form.

Validation of viewstate MAC failed. If this application is hosted by a
Web Farm or cluster, ensure that <machineKeyconfiguration specifies
the same validationKey and validation algorithm. AutoGenerate cannot
be used in a cluster.

We are not in a cluster situation. I believe it may be because there
is a delay in posting back so the viewstate is expiring. I wanted to
know if there is any way to increase the timeout of the view state, is
it bound to the session timeout (we are not using forms
authentication)?

Alternatively any way to turn this viewstate check off (it is a
restriced admin site so there should be no security problems although
I would prefer just to extend the timeout)

Oct 11 '06 #4
Hello Scott,

As for the ViewState validation error you encountered, there does exists
some issue that will result to the behavior. One is hosting web applicaiton
in webfarm environment which cause request send to different server (with
different machinekey) raise viewstate validation error. Another problem is
as you said, the ViewStateMac(enabled by default) is a randomly generated
digest value and it is not expected to work forever, and that's why
sometimes the server will also raise such error when use pickup a url from
the webcrawler's search result cache(which contains invalid viewstate
content).

So far, the ASP.NET's ViewState setting only provide the
"EnableViewStateMac" and "viewStateEncryptionMode" two configuration
options, and the "viewStateEncryptionMode" is specific to viewstate
encryption which is not used normally. As for ViewStateMac, we can only
control whether to enable it, but can not control the valid lifecycle of
the generated MAC value(it is internally fixed). BTW, since the error
will raise occasionally when the user postback a form after a long period
idle, do you think it possible that you embed some client-script in your
certain page (which need such protetion) and automatically postback the
form after a certain long period? Thus, if the user hasn't perform any
action on the form for a long time, the page will postback itself to make
its states refresh. Also, you can disable ViewStatemac for the certain
pages, however, there will still raise server-side exception when the
ViewState is corrupted.

Please feel free to post here if you have any other ideas or questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 12 '06 #5
Hi

Thanks for your reply, does the sentence "Also, you can disable ViewStatemac
for the certain pages, however, there will still raise server-side exception
when the
ViewState is corrupted." mean that changing the ViewStatemac setting even in
the web.config will not necessarily fix the problem?

Scott
--
Scott
"Steven Cheng[MSFT]" wrote:
Hello Scott,

As for the ViewState validation error you encountered, there does exists
some issue that will result to the behavior. One is hosting web applicaiton
in webfarm environment which cause request send to different server (with
different machinekey) raise viewstate validation error. Another problem is
as you said, the ViewStateMac(enabled by default) is a randomly generated
digest value and it is not expected to work forever, and that's why
sometimes the server will also raise such error when use pickup a url from
the webcrawler's search result cache(which contains invalid viewstate
content).

So far, the ASP.NET's ViewState setting only provide the
"EnableViewStateMac" and "viewStateEncryptionMode" two configuration
options, and the "viewStateEncryptionMode" is specific to viewstate
encryption which is not used normally. As for ViewStateMac, we can only
control whether to enable it, but can not control the valid lifecycle of
the generated MAC value(it is internally fixed). BTW, since the error
will raise occasionally when the user postback a form after a long period
idle, do you think it possible that you embed some client-script in your
certain page (which need such protetion) and automatically postback the
form after a certain long period? Thus, if the user hasn't perform any
action on the form for a long time, the page will postback itself to make
its states refresh. Also, you can disable ViewStatemac for the certain
pages, however, there will still raise server-side exception when the
ViewState is corrupted.

Please feel free to post here if you have any other ideas or questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 13 '06 #6
Thanks for your reply Scott,

Yes, IMO "turn off ViewStateMac" is not the way to fix the problem. This is
because if we turn off the ViewStateMac check, when a problem page (with
invalid viewstate) postback, the server-side will not verify the viewstate
since MAC is turned off, however, when the page framework parse the
viewstate, it will encounter problem which will raise some unexpected error
and this will be more ambiguous than a ViewState validation error. Do you
think so?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by theo | last post: by
9 posts views Thread by John Kirksey | last post: by
1 post views Thread by Ralph Soons | last post: by
2 posts views Thread by Janaka | last post: by
11 posts views Thread by Nad | last post: by
1 post views Thread by Tim | last post: by
10 posts views Thread by Robert | last post: by
reply views Thread by tynorton | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.