title: HttpWebRequest using Basic authentication
body: <p>I'm trying to go through an authentication request that mimics the "basic auth request" we're used to seeing when setting up IIS for this behavior.</p>
  
  <p>The URL is: <a href="https://telematicoprova.agenziadogane.it/TelematicoServiziDiUtilitaWeb/ServiziDiUtilitaAutServlet?UC=22&amp;SC=1&amp;ST=2" rel="noreferrer">https://telematicoprova.agenziadogane.it/TelematicoServiziDiUtilitaWeb/ServiziDiUtilitaAutServlet?UC=22&amp;SC=1&amp;ST=2</a><br>
  (warning: https!)</p>
  
  <p>This server is running under UNIX and Java as application server.</p>
  
  <p>This is the code I use to connect to this server:</p>
  
  <pre><code>CookieContainer myContainer = new CookieContainer();
  HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://telematicoprova.agenziadogane.it/TelematicoServiziDiUtilitaWeb/ServiziDiUtilitaAutServlet?UC=22&amp;SC=1&amp;ST=2");
  request.Credentials = new NetworkCredential(xxx,xxx);
  request.CookieContainer = myContainer;
  request.PreAuthenticate = true;
  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  </code></pre>
  
  <p>(I copied this from another post on this site). But I receive this answer from the server:</p>
  
  <blockquote>
    <p>The underlying connection was closed: An unexpected error occurred on
    a send.</p>
  </blockquote>
  
  <p>I think I tried every possible task my knowledge on C# has to offer me, but nothing...</p>