Quick tip for deploying ASP.NET Ajax to a web farm


If you are having issues with your ASP.NET Ajax application after you deployed it in a web farm and you notice that your partial page refreshes are not working, or you have javascript null reference errors, the problem lies in a config setting.  By default the setting for the MachineKey in ASP.NET is AutoGenerate, so when the session hops from one server to another the next server can't deserialize the previous server's values.  Here's what we did to fix it.


1.  Uninstall the ASP.NET Ajax installation on each server in the cluster and reinstall the same bits on each server.  This will ensure that all servers are working from the same installation.  You can skip this step if you're sure that all servers have the same installation on them and no prior installation hanging around on the machine.  Remember to do an iisreset.  If you are receiving the error "Sys is undefined", this is probably what you need to do.


2.  Generate a machine key by following this article: http://msdn2.microsoft.com/en-us/library/ms998288.aspx.  There's a C# example at the bottom you can cut and paste into a console app and generate your key.  Grab that key and place it in the machine config on each of the servers.  This will make sure all the servers are using the same key to encode the viewstate. 


Hope this saves you some time and headaches.

Skip to main content