With Hosted Websites running on our Public Cloud platform, a site will not always be running from the same server, due to the way the infrastructure is engineered. This does not mean the content of the sites change, but the server on which the actual ‘w3wp.exe’ process may change servers occasionally depending on current load and physical resources, in order to maintain the best possible performance.
However, when it comes to login sessions for specific sites, such as a shopping cart or message board forum, if the user is logged in when the site is moved between servers, the end user may experience an ASP.NET error related to ‘Invalid Viewstate’. All ‘web.config’ files use what is called a ‘MachineKey’, which is an element to control tamper proofing and encryption of ViewState, forms authentication tickets, and role cookies.
When a site is running on a single server, the ‘MachineKey’ element can be set to auto-generate encryption values from the server itself, and this works without any issue. Yet, when the site’s worker process is moved between servers, this value changes when it is auto-generated, hence causing the ‘Invalid ViewState’ errors.
There is a method of resolving this issue, and that is by implementing a static MachineKey into the site’s ‘web.config’ file, so that no matter what server the worker process is running from, the encryption and decryption algorithm will remain the same, preventing the ‘Invalid ViewState’ errors.
There are many sites on the Internet which you can use to generate a static MachineKey, such as the URL below:
Once you have generated the MachineKey, you will need to implement it into your ‘web.config’ file.
Before making any alterations to the ‘web.config’ file, it is best practice to always create a backup of the file, so the changes can be easily reverted if need be.
Once you have a backup copy of the file created, open it and find the ‘machineKey’ section, overwriting the existing code.
From there, you can copy and paste code generated from the above URL, or any site which can perform machineKey generation, and paste it into the ‘web.config’ file.
Saving the file will cause your site’s application pool to recycle, however once it is back, the issue should be resolved.
If you need any assistance with this process at all, please don’t hesitate to contact our Technicial Support Department.