I am uploading a zip file using an HttpWebRequest and a PUT operation
to Sharepoint (2003) from a Windows Form application. When I upload
the same file using the Sharepoint Portal Web UI itself, the file
uploads in 1/3 the time. If I copy the file over the network using
Windows Explorer, it also copies in about 1/3 of the time.
I don't understand why it is taking so much longer transferring it in
this way.
I've tried several variations of this code, but there's no difference:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = userNetworkCredentials;
request.Method = "PUT";
request.ContentType = "application/octet-stream";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data,0,data.Length);
stream.Close();
response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
temp = reader.ReadToEnd();
reader.Close();
Anybody know a way to improve the performance?
tregewitz@yahoo.com - 07 Mar 2008 21:52 GMT
I've now isolated the problem though I don't have a solution yet. The
file actually is being sent 3 times. But the first 2 times it is
being sent without the proper credentials. The server responds with
401-Unathorized. Apparently the HttpWebRequest has to go through 3
iterations of negotating security credentials before it gets it
right. Even when the Preauthenticate property is set to true, it
doesn't matter for the first request.