在WEB场中,动态网页往往会因为几台主机做了负载而产生SESSION丢失的问题,网上也有很多的介绍,我这里只将我经历的过程给大家分享一下:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
validationKey = CreateKey(20);
decryptionKey = CreateKey(24);
protected
string
CreateKey(
int
len)
{
byte
[] bytes =
new
byte
[len];
new
RNGCryptoServiceProvider().GetBytes(bytes);
StringBuilder sb =
new
StringBuilder();
for
(
int
i = 0; i < bytes.Length; i++)
{
sb.Append(
string
.Format(
"{0:X2}"
,bytes[i]));
}
return
sb.ToString();
}
|
1
2
3
4
5
6
7
|
<?
xml
version
=
"1.0"
?>
<
configuration
>
<
system.web
>
<
machineKey
validationKey
=
"3FF1E929BC0534950B0920A7B59FA698BD02DFE8"
decryptionKey
=
"280450BB36319B474C996B506A95AEDF9B51211B1D2B7A77"
decryption
=
"3DES"
validation
=
"SHA1"
/>
</
system.web
>
</
configuration
>
|