1
下
检索从Windows证书存储的问题,使用C#在ASP.net网站IIS下的凭据,我使用下面的代码检索ASP.net网站使用C#从Windows通用证书存储证书IIS
本地计算机和Windows 10 IIS它的工作正常。但是当我尝试托管在Windows Server 2012 R2不工作。 我的代码:
var cm = new Credential();
cm.Target = "targetname";
cm.Type = CredentialType.Generic;
if (!cm.Exists())
{
Console.WriteLine("cm is null");
}
cm.Load();
Console.WriteLine(cm.Password);
Console.WriteLine(cm.Username);
以上代码的Windows Server的IIS下2012 R于运行。但上面的代码无法检索用户名和密码(cm始终为空)我在控制台应用程序中使用了相同的代码,并且工作正常。请让我知道任何需要遵循的特殊说明。