Umbraco HttpWebRequest using Basic authentication
t
Where can I integrate the following theme entry process in Umbraco. I want to add logins only to those that belong to this username and password
Copy code
c#
var username   = "abc";
var password   = "123";
string encoded = System.Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1")
                               .GetBytes(username + ":" + password));
httpWebRequest.Headers.Add("Authorization", "Basic " + encoded);
k
It's been a few years since iso-8859-1 was the default encoding for basic auth. Both the specification and all browsers use utf-8 nowadays. You might want to verify that the server you're sending this to actually uses iso-8859-1 for non-ascii usernames/passwords. If not, just use the built-in
NetworkCredential
instead https://learn.microsoft.com/en-us/dotnet/api/system.net.networkcredential?view=net-8.0
31 Views