I have a web application hosted by a set of load-balanced servers. I have an ASP.NET text box and button on the master page for getting a value and searching for it in the database. The search result is displayed on a page called search.aspx that takes a query string with the value entered in the text box placed on the master page.
The button on the master page simply Respose.Redirect to the search.aspx page with the query string mentioned.
Sometimes the search is performed peacefully, some other times the following exception is thrown:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
I can't get the machine key be the same on all servers because they host other sites. I thought that this was because of the set of load-balanced servers. I tried EnableViewStateMac="false", ValidateRequest="false", EnableEventValidation="false" but it makes no difference.
I tried the following solution:
- Set the PostBackUrl of the button on the master page to the search.aspx page and remove Response.Redirect in the Click event handler of the button.
- Read the value of Request.Form["SearchCriteriaTextBox"] in the load of the search.aspx page.
But actually I found that it works when the pages don't inherit a master page and that's not my case. So What to do?????
Thank you for any help.