0

I have the following code:

var myImage = Image.FromStream(imageStream);

As soon as my application hits this line of code, it throws the following exception:

  System.Net.WebException: The request was aborted: 
           The connection was closed unexpectedly.

Note that my application is on a shared host and exception is only thrown on images files greater than 2MB.

Is there any workaround for this?

शेखर
  • 17,412
  • 13
  • 61
  • 117
Babu James
  • 2,740
  • 4
  • 33
  • 50

2 Answers2

0

try increasing the response time in the web config file.

<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
  ...
  <system.web>
   <httpRuntime executionTimeout="90" maxRequestLength="4096"
    useFullyQualifiedRedirectUrl="false"
    minFreeThreads="8"
    minLocalRequestFreeThreads="4"
    appRequestQueueLimit="100" />
 </system.web>
... 
</configuration>

For more information, please, see msdn page.
How to increase time in web.config for executing sql query

Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117
0

I found the issue. I have debug=true in the web.config file which would overwrite the executionTimeout value to system default.

Babu James
  • 2,740
  • 4
  • 33
  • 50