asp.net例外:无法联系本地安全机构

时间:2013-05-27 16:31:54

标签: c# asp.net windows authentication

应用程序调用处理程序表单其他(Windows身份验证) 应用程序来自应用程序B的调用处理程序和Windows身份验证下的应用程序B

当我使用以下代码异常(无法联系本地安全机构)时显示 代码:

WebClient webClient = new WebClient();

            webClient.Credentials = new NetworkCredential(UserName, password, domain name);                

                string url = (handler url)

                webClient.DownloadFile(url, Context.Server.MapPath(imagePath));

2 个答案:

答案 0 :(得分:0)

在我们的域中,您需要使用need domain来打开。例如Domain \ OurUserName

ASP.Net error: The Local Security Authority cannot be contacted

答案 1 :(得分:0)

我的问题已经通过更新的代码解决了

WebClient webClient = new WebClient();

var credCache = new CredentialCache();                     credCache.Add(new Uri(url),                           “Negotiate”,新的NetworkCredential(serviceUserName,servicePassword,serviceDomainName));                     webClient.Credentials = credCache;                     webClient.DownloadFile(URL,路径);

获取帮助检查here