cURL with user authentication in C#
Solution 1:
HTTP Basic authentication requies everything after "Basic " to be Base64-encoded, so try
request.Headers["Authorization"] = "Basic " +
Convert.ToBase64String(Encoding.ASCII.GetBytes(authInfo));
Solution 2:
The solution to my question was changing the ContentType property. If I change the ContentType to
request.ContentType = "text/xml";
the request works in both cases, if I also convert the authInfo to a Base64String in the last example like Anton Gogolev suggested.
Solution 3:
Using:
request.ContentType = "application/xml";
request.Credentials = new NetworkCredential(GEOSERVER_USER, GEOSERVER_PASSWD);
also works. The second sets authentication information.