2013-02-21 50 views
0

我有以下代碼:ASP.NET連接意外關閉的> 2MB的圖像文件處理

var myImage = Image.FromStream(imageStream); 

只要我的應用程序命中這行代碼,它拋出以下異常:

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

請注意,我的應用程序位於共享主機上,並且僅在大於2MB的圖像文件上引發異常。

有沒有解決方法?

回答

0

嘗試增加Web配置文件中的響應時間。

<?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> 

欲瞭解更多信息,請參閱msdn page
How to increase time in web.config for executing sql query

+0

是我目前擁有的 – 2013-02-21 08:16:32

0

我發現了這個問題。我在web.config文件中有debug=true,它會將executionTimeout值覆蓋爲系統默認值。