Click here to Skip to main content
11,633,235 members (85,017 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hello
I wrote a c# desktop app that use webrequest/response to post large records to a remote website.

when i test the app locally, specifying my localhost site as my url, the app works fine but when i try to connect to a remote (live) website the application becomes very slow:it takes more than two days to upload 2,000 records.

Please I need a more reliable and faster way to send this records.
(n.b.:I am using Backgroundworker to multithread)
below is a copy of my code:

<pre lang="cs">public string PostDataToWeb(string postData, string url)
         {
                     string retu;
                     WebRequest request = WebRequest.Create(url);
                     request.Method = &quot;POST&quot;;
                     byte[] byteArray = Encoding.UTF8.GetBytes(postData);

                     request.ContentType = &quot;application/x-www-form-urlencoded&quot;;

                     request.ContentLength = byteArray.Length;

                     using (Stream dataStream = request.GetRequestStream())
                     {
                           dataStream.Write(byteArray, 0, byteArray.Length);
                     }
                     using (WebResponse response = request.GetResponse())
                     {
                           retu = (((HttpWebResponse)response).StatusDescription);
                     }
                     return retu;
         }</pre>


I now included the above method in a loop that loop through a datatable for all the records and send them row by row.

thanks in anticipation.
tosin
Posted 18-Aug-10 0:16am
tosinp483

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If it's faster locally, then your network speed is the issue. Nothing is going to make it faster except making your data smaller. What if you zip it and send a zip ?
  Permalink  
Comments
tosinp at 18-Aug-10 6:36am
   
the problem is: I am sending the data one record at a time, so even if the network speed is slow(which is not), it should not be so slow as sending 2000 records in two days. out of 10,000. I have tried sending the data as a single file, then, it uploads upto 500 records in 2 minutes and time out. But I did that in PHP. I want to use c# and I want ti to be a desktop app

Thanks so much for ur swift response
tosinp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,618
1 Sergey Alexandrovich Kryukov 8,189
2 Mika Wendelius 6,415
3 F-ES Sitecore 2,321
4 Suvendu Shekhar Giri 2,075


Advertise | Privacy | Mobile
Web01 | 2.8.150728.1 | Last Updated 18 Aug 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100