2009-04-24 55 views

回答

1

只要篡改保护/ MAC关闭,我相信它可以。

+0

有很多关于机器钥匙的答案,但是你的答案是可以接受的,那么什么是“防篡改/ MAC”设置,以及在哪里可以找到关于这个的信息? – 2009-09-11 07:56:44

1

是的,web.config中的'machineKey'设置在每台服务器上必须相同。

1

在所有节点上使用identic machineKey。把它放在machine.config或web.config中

2

是的,你可以。有几个选项可以确保您的视图状态可以在服务器场中的每台服务器上解码。通常,您在每台服务器上手工设置每台machine.config中的machineKey,使它们都一样。 But there are other options as well.

0

阅读这篇文章:How To: Configure MachineKey in ASP.NET 2.0

基本上,您使用此代码:

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); 
    } 
} 

产生导致用户在你的农场共享的machineKey。