我在生产服务器中部署应用程序时遇到此错误,但在我的本地计算机中它运行良好。此行生成错误(rsa.FromXmlString(xmlKey);在SignAndSecureData函数中)。任何遇到以下错误的人?我还在错误消息下面添加了代码段。
Error in: /sample.html.
Error Message:The profile for the user is a temporary profile.
Source: mscorlib
Method: System.Security.Cryptography.SafeProvHandle CreateProvHandle(System.Security.Cryptography.CspParameters, Boolean)
Stack Trace: at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
at System.Security.Cryptography.RSA.FromXmlString(String xmlString)
at website1.CryptoHelper.SignAndSecureData(String xmlKey, String[] values) in C:\website1\CryptoHelper.cs:line 52
at website1.CryptoHelper.SignAndSecureData(String[] values) in C:\website1\CryptoHelper.cs:line 40
-----------------------------代码----------------- --------------
public static string SignAndSecureData(string[] values)
{
string xmlKey = "<RSAKeyValue><Modulus>p9HPjw9PMOCbYlu7YiE5chOOLgLfPR4L9jmcAyjrRsAekw0Z/xhs9G3Nl2P5G+/kMangrwg0egh2ium+3j5NuB0UGFEs8jKk/deSwwbxsxp+0p1JoY6jkHaQ1ItmrDVU5TZGjh7jNjBn5TpsrcFdxkslJp1x9ki248E7z7q1uhs=</Modulus><Exponent>AQAB</Exponent><P>27HXXHera3Voek0qg5pJf8wsl0Tq4xGl+tl1/f0rt1g6hyx4egS4/finWlptUnTnXu81oboYq7mI/kjzFiOPbQ==</P><Q>w41mCFTmdmINIo85D/8umTdwDsC+FOVlyYTVlw/xHBc/HxQQVOQOCVOJA9kZsVSUBr6fXY3yfSe/jxQXyzOSpw==</Q><DP>QCo38TzOZys6YYYKJbe5QccbOu8Y/0rXRGWhDZaU3w64wWQep9ybPyoRjtUcWtnj/Zk1+89Dh1xAA6zAurWWHQ==</DP><DQ>dsWiDDtswshpC+2LjgDCz8KRKBS/Hrf567zncdn36sTfzMOF69mcAOQg2xp4dXFWewY6izsU5hlHSuK8VOodDw==</DQ><InverseQ>WAmgU5XPgZNVXDMqYePpVZzQoiOblX4UlM21xTt/ZmvC7+af0c00LqOW4nbkwDqKCuRcD8X5Yr3H7IraaANjyg==</InverseQ><D>QbMRGAe9T/xOuLYC6Qrqy28+dWLodKvjsPSi0FXfriYekiFJ8SVl2ld2anNYHgjPhGXmMX/7016m0gFqmOU5VV1zzHVH0c0wecnKhhnJC+irjNgNwy9xwM1mnVoce9auk2qiAMhr2cL1NtwUf8cuXBfzm39ZF9Sxsn4fE1+p+ck=</D></RSAKeyValue>";
return SignAndSecureData(xmlKey, values);
}
public static string SignAndSecureData(string xmlKey, string[] values)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<x></x>");
for (int i = 0; i < values.Length; i++)
_AddNode(xmlDoc, "v" + i.ToString(), values[i]);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlKey);
byte[] signature = rsa.SignData(Encoding.ASCII.GetBytes(xmlDoc.InnerXml),
"SHA1");
_AddNode(xmlDoc, "s", Convert.ToBase64String(signature, 0, signature.Length));
return EncryptCookie(xmlDoc.InnerXml);
}