Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Uploading files using HttpWebRequest and PUT takes too long

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tregewitz@yahoo.com - 27 Feb 2008 22:59 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.