WebClient Timeout Exception

From: Michael Fields (Fields_at_discussions.microsoft.com)
Date: 02/28/05


Date: Mon, 28 Feb 2005 12:39:04 -0800

I have a problem with the WebClient and uploading a file to a web server. The
stream object returned from the WebClient.OpenWrite menthod throws a timeout
exception when using this method on computers w/ low bandwith ( < = 256 kbs).
The exception occurs when I call the Stream.Close method. Here is the code:

WebClient client = new WebClient();
Stream postStream = client.OpenWrite(uri,"PUT");
postStream.Write(buffer, 0, buffer.Length);
postStream.Flush();
postStream.Close();

Buffer length is around 4 MB. The code shown is from a Windows App that
consumes a web service. I have tried several approaches, but haven't found a
working solution, such as..

Writing a 2k chunk and calling flush until the entire buffer is read
Writing a webservice method that takes an array of bytes

Any suggestions would be extremely helpful
Thanks in advance



Relevant Pages

  • Re: WebClient Timeout Exception
    ... > I have a problem with the WebClient and uploading a file to a web server. ... > Buffer length is around 4 MB. ... > Writing a 2k chunk and calling flush until the entire buffer is read ... > Writing a webservice method that takes an array of bytes> ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WebClient Not posting to Client
    ... Try the WebRequest class if you want to POST data to a web server. ... example file the file upload server control, ... WebClient Not posting to Client ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Downloading images from a web server
    ... WebClient wc = new WebClient; ... How can I download an image from a web server provided I have the url ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Delete (remote)
    ... Only if the web server offers a way ... through some sort of service (in which case it will be custom to the ... Is it possible to delete a file from remote by using the WebClient? ...
    (microsoft.public.dotnet.languages.csharp)
  • Passing security credentials to ASP from .net
    ... WebClient wc = new WebClient; ... NameValueCollection nvc = new NameValueCollection; ... buffer = wc.UploadValues; ...
    (microsoft.public.dotnet.framework.aspnet.security)