Click here to Skip to main content
15,610,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello

I have an application that upload picture from aspx pages. I had aspx pages on my PC that has windows7(IIS7). I moved them in a server that has windows 2003 server(IIS6).

Now when i upload a 50KB picture or some text(about 1 KB) i receive this error message in my .Net App:

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 changed some settings:

web.config: httpruntime max maxRequestLength to 32768

metabase.xml: AspMaxRequestEntityAllowed to 10000000

But still I receive this error.

I use this code at server side:
byte[] bytes = new byte[Request.InputStream.Length];
Request.InputStream.Read(bytes, 0,(int)Request.InputStream.Length);

And this code at client side:
new WebClient("page address").UploadData(MyPicture);
Posted
Updated 11-Jan-10 21:30pm
v2

I think you need to use
<httpRuntime maxRequestLength="8192" />

Check this lovely article :
http://msdn.microsoft.com/en-us/kb/kb00323245.aspx#XSLTH3150121122120121120120[^]

Cheers
:rose:
 
Share this answer
 
Well, Actually I showed how to do this.

Did you read the article I specified. I think you need to modify the Machine.config as it will always override the value with this one.

Normal files in asp.net defaults to 4,096 kilobytes(4MB), if you need larger than this, go to \System Root\Microsoft.NET\Framework\Version Number\Config folder and change
<httpRuntime 
executionTimeout="90" 
maxRequestLength="4096"
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"
/>


To the value you need. I dont think changing to web.config works.

I hope this will solve the issue. :thumbsup:
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900