C# SSL Basic Access Authentication

authentication, c#, ssl

Solution

Assuming you use a WebRequest, you attach a CredentialCache to your request:

        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();

Problem

I want to request reports from a third party and they require "Basic Access Authentication" via POST: ``` Your client application must use Basic Access Authentication to send the user name and password. ``` Can someone point me in the right direction? Edit: I did see this post but there are two answers and I'm not sure if thats what I need to do or which one is the preferred method.

Original source

Related problems