tags:

views:

84

answers:

5

with Asp.net 2.0 can a viewstate generated on Server1 be used by server2 in the same farm?

+1  A: 

As long as tamper protection/MAC is turned off I believe it can.

Arnshea
There are a lot of answers relating to the Machine Keys, however yours is the accepted answer, so what is the "tamper protection/MAC" setting and where would one find info on this?
Mark Redman
+1  A: 

Yes, your 'machineKey' setting in the web.config must be the same on each server.

Peter Mourfield
+1  A: 

Use an identic machineKey on all nodes. Put it in machine.config, or web.config

baretta
+2  A: 

Yes, you can. There are several options for making sure that your viewstate can be decoded on each server in the farm. Generally, you set the machineKey in each machine.config by hand on each server so they are all the same. But there are other options as well.

JP Alioto
A: 

Read this article: How To: Configure MachineKey in ASP.NET 2.0

Basically, you use this code:

using System;
using System.Text;
using System.Security;
using System.Security.Cryptography;

class App {
  static void Main(string[] argv) {
    int len = 128;
    if (argv.Length > 0)
      len = int.Parse(argv[0]);
    byte[] buff = new byte[len/2];
    RNGCryptoServiceProvider rng = new 
                            RNGCryptoServiceProvider();
    rng.GetBytes(buff);
    StringBuilder sb = new StringBuilder(len);
    for (int i=0; i<buff.Length; i++)
      sb.Append(string.Format("{0:X2}", buff[i]));
    Console.WriteLine(sb);
  }
}

to generate a machinekey that's shared across your farm.

Christopher_G_Lewis