基础连接已关闭 [英] The underlying connection was closed

查看:170
本文介绍了基础连接已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有一个从aspx页面上传图片的应用程序.我在装有Windows7(IIS7)的PC上有aspx页面.我将它们移至具有Windows 2003 Server(IIS6)的服务器中.

现在,当我上传50KB图片或一些文本(大约1 KB)时,我在.Net App中收到此错误消息:

System.Net.WebException:基础连接已关闭:接收时发生意外错误. ---> System.IO.IOException:无法从传输连接中读取数据:现有连接被远程主机强行关闭. ---> System.Net.Sockets.SocketException:现有连接被远程主机强行关闭


我更改了一些设置:

web.config:httpruntime max maxRequestLength到32768

metabase.xml:AspMaxRequestEntity允许为10000000

但是我仍然收到此错误.

我在服务器端使用此代码:

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);

推荐答案

我认为您需要使用
<httpRuntime maxRequestLength="8192" />

检查这篇可爱的文章:
http://msdn.microsoft.com/en-us/kb/kb00323245.aspx#XSLTH3150121122120121120120 [ ^ ]

干杯
:rose:
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:


嗯,实际上我展示了如何做到这一点.

您读过我指定的文章吗?我认为您需要修改Machine.config,因为它将始终用此值覆盖该值.

asp.net中的普通文件默认为4,096 KB(4MB),如果需要更大的文件,请转到\System Root\Microsoft.NET\Framework\Version Number\Config文件夹并更改
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"
/>



达到您所需要的价值.我认为更改为web.config是行不通的.

我希望这可以解决问题. :thumbsup:



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

I hope this will solve the issue. :thumbsup:


这篇关于基础连接已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆