Saturday, March 24, 2012

System.Net.WebException:

Hi,
I am trying to make a simple file updload WinForm app.
Here's the code:
WebClient webClient = new WebClient();
webClient.UploadFile(new Uri("http://localhost/WebSite/Upload.aspx"),
"c:\\bin.zip");
My IIS 5.1 Web server uses default configuration.
If the file is less than 5Mo everything works fine. If the file is too big I
get this exception:
System.Net.WebException: The underlying connection was closed: An unexpected
error occurred on a receive. --> System.IO.IOException: Unable to read data
from the transport connection: An existing connection was forcibly closed by
the remote host. --> System.Net.Sockets.SocketException: An existing
connection was forcibly closed by the remote host
I will never have to upload more than 30Mo.
Do you now how I can correct this issue ?In the web.config file, the httpRunTime element has a maxRequestLength which
restricts the length in bytes of any HTTP request. The default is 4MB.
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"zolof" <zolof@.discussions.microsoft.com> wrote in message
news:C12D293F-C3B4-401C-99A6-7A10DB48B8BE@.microsoft.com...
> Hi,
> I am trying to make a simple file updload WinForm app.
> Here's the code:
> WebClient webClient = new WebClient();
> webClient.UploadFile(new Uri("http://localhost/WebSite/Upload.aspx"),
> "c:\\bin.zip");
> My IIS 5.1 Web server uses default configuration.
> If the file is less than 5Mo everything works fine. If the file is too big
> I
> get this exception:
> System.Net.WebException: The underlying connection was closed: An
> unexpected
> error occurred on a receive. --> System.IO.IOException: Unable to read
> data
> from the transport connection: An existing connection was forcibly closed
> by
> the remote host. --> System.Net.Sockets.SocketException: An existing
> connection was forcibly closed by the remote host
> I will never have to upload more than 30Mo.
> Do you now how I can correct this issue ?
>
That's great. Thanks a lot for your help.

0 comments:

Post a Comment