Domain credentials for a WebClient class don't work

前端 未结 1 553
自闭症患者
自闭症患者 2020-12-01 12:08

I\'m trying to get a html source of a website through C# code. When I access the site with windows authentication the following code works:

using (WebClient          


        
相关标签:
1条回答
  • 2020-12-01 12:44

    Try this:

    CredentialCache cc = new CredentialCache();
    cc.Add(
        new Uri("http://intranet/"), 
        "NTLM", 
        new NetworkCredential("username", "pass", "domain"));
    client.Credentials = cc;
    
    0 讨论(0)
提交回复
热议问题