C# SSL 基本访问认证

标签 c# authentication ssl

我想从第三方请求报告,他们需要通过 POST 进行“基本访问身份验证”:

Your client application must use Basic Access Authentication 
to send the user name and password.

有人能指出我正确的方向吗?

编辑:我确实看到了 this post但有两个答案,我不确定这是否是我需要做的,或者哪个是首选方法。

最佳答案

假设您使用 WebRequest,您将 CredentialCache 附加到您的请求:

        NetworkCredential nc = new NetworkCredential("user", "password");
        CredentialCache cc = new CredentialCache();
        cc.Add("www.site.com", 443, "Basic", nc);


        WebRequest request = WebRequest.Create("https://www.site.com");
        request.Credentials = cc;
        request.PreAuthenticate = true;
        request.Method = "POST";

        // fill in other request properties here, like content

        WebResponse respose = request.GetResponse();

关于C# SSL 基本访问认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1127223/

相关文章:

c# - WebBrowser IFrame 访问导致未经授权的访问?

c# - 为什么我的 dllimport 函数总是返回 true?

c# - 使用 Xamarin 表单的 HttpClient

php - 如果未登录 WordPress,则重定向到特定页面

javascript - Facebook Javascript API : tracking user adding application for first time

ssl - certreq -submit commnd 要求选择 2 个证书颁发机构之一

c# - 用单个全局try catch block 替换多个try catch

php - 如何访问 Sym2 FOSUserBundle 自定义 UserChecker 中的请求对象

java - Glassfish v4 和 SSL - 管理员不再工作

wordpress - Cloudflare 525 在 Wordpress 上使用 HTTPS