Invalid_Viewstate

A

Alvin Bruney [MVP - ASP.NET]

That's good stuff, i'll push this out to MSDN as a solution. P.J. send me
your full name if you require credit for the solution (e-mail address removed)
subject line Invalid Viewstate

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 
H

Huzaifa Tapal

Unfortunately, I tried this solution out for my scenario and it does not
work. Here is what my application is running on:

- Windows 2003 HyperThreaded II6 Server
- Application Pool's identity is user account
- Using FormsAuthentication
- Using Server.Transfer to go from page to page taking advantage of
performance gains and the Context to pass query values between pages.

If I disable the EnableViewStateMac in my web.config, I am no longer
running into this problem. What is interesting is that I had the same
application running on another Windows 2003 machine about 4 months ago
and it did not error out like this. The only difference between the
current one and the old one is that the current one is HyperThreaded.

The machine key solution might work for Web Farm scenarios but not
regular sites running on a shared production box at a web hosting
company.
 
P

P.J

There are 3 possible solutions to this problem:

1st solution: Disable the application pool idle worker process shutdown
via IIS 6.0 console | <your_application> properties

2nd: I think the code snippets provided by danpak6 persist the
viewstate so it stays available on subsequent hit

3rd: In the machine.config file of your server, in the system.web
section, change the validationKey setting from the default (which is
Autogenerate) to a permanent key you generated (see above post to make
the tool that will generate one for you).

I think that sums it all.
 
H

Huzaifa Tapal

Of the three solutions you suggested, none of them work.

1st solution: Disable the application pool idle worker process shutdown
via IIS 6.0 console | <your_application> properties

-- Did that under the Performance tab, recycled the application pool,
still the error persists.

2nd: I think the code snippets provided by danpak6 persist the viewstate
so it stays available on subsequent hit

-- Although this was not giving any error, the application was behaving
oddly. It would keep logging me out when it usually three the Invalid
ViewState error otherwise. Then accessing a secured area, I would
automagically be logged in again.

3rd: In the machine.config file of your server, in the system.web
section, change the validationKey setting from the default (which is
Autogenerate) to a permanent key you generated (see above post to make
the tool that will generate one for you).

-- This is the solution, in my previous reply I mentioned does not work
(possibly in a non-web farm environment).
 
A

Alvin Bruney [Microsoft MVP]

Did that under the Performance tab, recycled the >application pool,still
the error persists.
You should manipulate the settings so that the application does not recycle.
This is not what you have said.


--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
 
P

P.J

In the Performance tab, uncheck the "Idle timeout" checkbox. By
default it is at 20 minutes, but unchecking it will leave it in memory
and no shutdown (recycling) will happen again. Then, the the Recyling
tab, uncheck any 'recycling' option that are set.

Note: if you are connected to your site, make changes to the
application pool setting, and then continue to browser, you might have
the error since the worker process did recycle when you applied the
settings to the pool. But from a fresh new session, you shouldn't
received the error.

Hope that will you better!
P.J
 
D

danpak6

Hi Huzaifa Tapal,

The unofficial solution is to set the enableViewStateMac property to
True on the page you'll be transferring to, then set it back to False.
This records that you want a definitive False value for this property
and resolves the bug.

Best,

Daniel
 
H

Huzaifa Tapal

Well turning off the recycling options and the idle timeout still did
not work. The wierd thing is that this only happens after doing
Server.Transfer and after Forms Authentication.

Turning the EnableViewStateMac to false fixes the problem, however,
since that is not reccommended I want to find a better solution to this.

I am surprised Microsoft is not doing anything about this. I believe
this is a huge bug in ASP.NET
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top