Can't use the http Basic-Authentication the statuscode is always System.Net.HttpStatusCode.Unauthorized.
With the normal MessageHandler the code works.
How to use the http Basic Authentification?
Thanks for your support!
Sample Code:
try
{
var tlsConfig = new TLSConfig()
{
DangerousAcceptAnyServerCertificateValidator = true,
Pins = new List<Pin>()
{
new Pin()
{
Hostname = "*",
PublicKeys=new string[]{ }
}
}
};
var handler = new NativeMessageHandler(false, tlsConfig);
HttpClient client = new HttpClient(handler);
var webdavUrl = new Uri("https://ubuntu/remote.php/dav/files/zpush");
var passwordCache = new CredentialCache();
passwordCache.Add(webdavUrl, "Basic", new NetworkCredential("xxx", "secret"));
handler.Credentials = passwordCache;
handler.UseDefaultCredentials = false;
handler.PreAuthenticate = true;
var request = new HttpRequestMessage(new HttpMethod("PROPFIND"), webdavUrl);
var response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
var satuscode = response.StatusCode;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Can't use the http Basic-Authentication the statuscode is always System.Net.HttpStatusCode.Unauthorized. With the normal MessageHandler the code works. How to use the http Basic Authentification?
Thanks for your support!
Sample Code: