Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have created an ASP.NET-based relying party application and this application is deployed on farm-server where load balancing is enabled and sticky session is also used.

When request come from single server in that time its working fine but during the post back if request server is changed in that time it throws an exception "Key not valid for use in specified state".

I have tried to set same machine key on both server but still facing same problem.

I have found on net the alternative solution is set enableViewStateMac="false".

Can i use this, and what is demerit of this?

share|improve this question
    
How is your session state stored? See Scott Hanselman's post hanselman.com/blog/LoadBalancingAndASPNET.aspx for different options. –  James Skemp Jun 3 '11 at 12:11
add comment

1 Answer 1

To answer your question, according to MSDN:

This attribute should never be set to false in a production Web site.

(Of course, the default is also false ...) Which suggests to me that you want to be very careful doing this.

Can you include a link to the resource you found online that suggested you switch this off?

Next, according to an MSDN blog:

The problem is that if a POST back is performed and goes to a different server, you will get a nice little error message saying “Corrupt View State“.

To fix this, you can either set enableViewStateMac to false in the element or specify a common value for the validationKey attribute in the element across all servers (in the farm).

Which suggests to me that, unless the error message has changed (quite possible), this isn't what you're running into.

Take a look at this accepted answer - http://stackoverflow.com/questions/686873/allowing-session-in-a-web-farm-is-stateserver-good-enough/687162#687162 - over on Stack Overflow to make sure you're setup correctly.

MSDN also has an article ASP.NET Session State Overview that discusses setting up session state.

At this point, I think it's a configuration issue. Changing machine.config should have restarted the app pools, so that's probably not the issue.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.