Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The article you referenced says </p> <blockquote> <p>If the Microsoft Internet Information Services (IIS) Web server is configured to use Basic authentication, and you must set the HttpWebRequest.AllowWriteStreamBuffering property to false, you must send a HEAD request to pre-authenticate the connection before you send the POST or PUT request. </p> </blockquote> <p>EDIT - now with more clarification! </p> <p>To restate the article, if you want to send a large file to a destination which requires basic authentication, you'll need to issue two separate requests. The key here is that you are setting <code>PreAuthenticate = true</code>. Read the statement literally -- by setting the property to <code>true</code>, you are saying that you will authenticate any requests that you make <em>before you actually attempt them!</em> The framework doesn't know how you want to accomplish this pre-authentication, so you need to perform that action yourself, by sending a <code>HEAD</code> request to the destination. Think of the <code>HEAD</code> HTTP method as being a prologue to the actual request - it describes (or requests information about) a particular resource. </p> <p>So the process goes like this:</p> <ol> <li>Make a HEAD request to <code>http://someurl/aresource</code> containing the credentials you want to use when making future requests from this client to that server for the listed resource</li> <li>The server will respond (ideally) with "OK - you may proceed. You're authenticated"</li> <li>The server immediately regrets its' decision to allow the operation as it finds itself saving a very large file :-)</li> </ol> <p>I don't see you making that HEAD request anywhere in the code you posted - if it's not already there, add this at the beginning of your code (snipped from the sample article ref in OP):</p> <pre><code>//preAuth the request // You can add logic so that you only pre-authenticate the very first request. // You should not have to pre-authenticate each request. WRequest = (HttpWebRequest)HttpWebRequest.Create(URL); // Set the username and the password. WRequest.Credentials = new NetworkCredential(user, password); WRequest.PreAuthenticate = true; WRequest.UserAgent = "Upload Test"; WRequest.Method = "HEAD"; WRequest.Timeout = 10000; WResponse = (HttpWebResponse)WRequest.GetResponse(); WResponse.Close(); // Make the real request. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload