Why my ASP.NET / SQL Server web app crashes when resumed after a period of inactivity?
I wrote a simple query of a SQL Server database for my app. Multiple queries one after the other work fine. But if I leave the browser and the app active and do another query after a period of inactivity, the app crashes. It's not only slow; it actually crashes hard with the follwing error code:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validati开发者_JS百科onKey and validation algorithm. AutoGenerate cannot be used in a cluster.
What do I have to do in my code to prevent this? Thanks.
If you are using sessions perhaps your session expired and when you revisit that is the error?
Can you please post the error you are recieving.
Also if you are executing the query directly are you properly closing your connection. Its hard to say much more without better information like the exact error you get and how you define "crashing hard"
If its the MAC error I know what it is now. You are hosting in a shared hosting environment. You will need to explicitly provide a MAC value in your web.config file. The problem occurs because the belated request could be directed at a different server and there will be a mismatch between your application.
aspnetresources.com/tools/machineKey
精彩评论