Click here to Skip to main content
12,767,637 members (51,948 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
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;

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.
Posted 18-Aug-10 1:16am

1 solution

Rate this: bad
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 ?
tosinp 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

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 18 Aug 2010
Copyright © CodeProject, 1999-2017
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