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始終爲空)我在控制檯應用程序中使用了相同的代碼,並且工作正常。請讓我知道任何需要遵循的特殊說明。