【 以下文字转载自 JobHunting 讨论区 】 发信人: light009 (light009), 信区: JobHunting 标 题: IIS7.5 大于 64KB 文件不能下载 ? 发信站: BBS 未名空间站 (Tue Jun 23 12:47:53 2015, 美东) 大于 64KB 文件不能下载 (from C# code). 大于 文件不能完全下载, 只能下载 64KB , 然后 truncated. Why ? I have published a web service application (C# built in VS2010) to a desktop with IIS 7.5 win7. The web service has been hosted successfully on win 7. Now I can install the application on my laptop (win 7) by accessing the URL http://myDesktopName.domain.com/MyApp/MyAppSetup.msi pointing to a physical location in desktop E:myPathmyAppmyAppService.svc Now, in my application, I need to download (from C# on my laptop) a .dat file from my desktop to my local laptop by visiting the URL. The downlod function is webclient.downloadfile(URL, myLocalFileName) https://msdn.microsoft.com/en-us/library/ms144194%28v=vs.110%29.aspx. The URL is "http://myDesktopName.domain.com/MyApp/download.ashx?cmd=download&type=db&name=myDatasbase.dat" But, the downloaded file size is not correct. Sometimes, it is 0. Sometimes, it is 64KB. But, the original size s 4,000 KB. If the file size is larger than 64KB, none of them can bne downloaded. I got error: **connection was forcibly closed by remote server** on my laptop, and **error 504 gateway timeout** on my desktop. The file is binary and is not readable in any text editor. If I download the file from IE by visiting the same URL in address bar, the file can be downloaded correctly. Why the file cannot be downloaded correctly from my application if it is larger than 64 KB? I have set up minbytepersec as 0 in IIS on my desktop and set worker process as 8 for the application pool. And, increase timeout to 10 minutes. Is this a bug of win 7 ? because I found this at https://support.microsoft.com/en-us/kb/919797?wa=wsignin1.0 but, it is about win server 2003. My OS is win 7. I have done a lot of search about the error of 504 and connection-closed by remote server, but none of them work. In the IIS manager, ASP limit, max requesting entity body limit = 1073741824 // 1024 MB max allowed content length = 30000000 bytes // 28 MB I think it should be large enought to download a 4MB file. But, it still failed for any file size > 64 KB. this is C# code ran at VS2010. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Diagnostics; namespace datafile_updownload { class Program { static void Main(string[] args) { try { WebClient _client; _client = new WebClient(); // download // An ASP.net web service has been published on my myDesktopName with IIS7.5 string url = "http://myDesktopName.domain.com/MyApp/download.ashx?cmd=download&type=db&name=myFile"; Uri uri = new Uri(url); string tmp = @"C:\Temp\aFile.dat"; _client.DownloadFile(uri, tmp); // **if file size > 64KB**, ** exception jumped out here,** // Unable to read data from the transport connection: An existing connection was // forcibly closed by the remote host. // System.Net.WebExceptionStatus.UnknownError } catch(WebException ex) { Console.WriteLine("This program is expected to throw WebException on unsuccessful run." + "\n\nException Message :" + ex.Message); Console.WriteLine("Status : {0}", (ex.Status)); Console.WriteLine("Response: {0}", (ex.Response)); } } } }
【在 l******9 的大作中提到】 : 【 以下文字转载自 JobHunting 讨论区 】 : 发信人: light009 (light009), 信区: JobHunting : 标 题: IIS7.5 大于 64KB 文件不能下载 ? : 发信站: BBS 未名空间站 (Tue Jun 23 12:47:53 2015, 美东) : 大于 64KB 文件不能下载 (from C# code). 大于 文件不能完全下载, 只能下载 64KB : , 然后 : truncated. Why ? : I have published a web service application (C# built in VS2010) to a desktop : with IIS 7.5 win7. : The web service has been hosted successfully on win 7.
w*s
5 楼
no
【在 g*******s 的大作中提到】 : 大风歌吧 : 张旭阳
a*y
6 楼
web.config设置有问题吧。是wcf么? 如果是要把限制改大。both server and client side。
64KB desktop URL
【在 l******9 的大作中提到】 : 【 以下文字转载自 JobHunting 讨论区 】 : 发信人: light009 (light009), 信区: JobHunting : 标 题: IIS7.5 大于 64KB 文件不能下载 ? : 发信站: BBS 未名空间站 (Tue Jun 23 12:47:53 2015, 美东) : 大于 64KB 文件不能下载 (from C# code). 大于 文件不能完全下载, 只能下载 64KB : , 然后 : truncated. Why ? : I have published a web service application (C# built in VS2010) to a desktop : with IIS 7.5 win7. : The web service has been hosted successfully on win 7.
s*w
7 楼
大汉骑军? 张迈
l*9
8 楼
我不是这个 application 的开发人。 我知道 REST and SOAP. 但是不知道如何在代码里区分它们, REST 只是一种 architectural style。 SOAP 只是一种 protocol 。 我的 application service (published by IIS 7。5 to my desktop) 发布成功后, 交给用户的是一个 URL 指向我的 desktop 的一个文件夹。 用户可以从这个链接 下载并安装 这个 application 工具。 这个工具 有GUI, 可以 从的指向的文件夹 下载文件。 但是, 文件大于 64KB 就不能下载 或者只下载 64KB。 I got error: connection was forcibly closed by remote server on my laptop (client side), and error 504 gateway timeout on my desktop (server side). 我在IIS 7.5 manager, ASP property 里面 更改了 client connection test interval = 00:10:00 max requesting entity body limit = 1073741824 response buffering limit = 1073741824 request queu timeout = 00:10:00 script timeout = 00:10:00 in my web.config requestLimits maxAllowedContentLength="104857600" I used the same setting for the desktop's applicationHost/weblimits properties. 可是依然不能解决问题。 Any help would be appreciated.
client
【在 a**y 的大作中提到】 : web.config设置有问题吧。是wcf么? 如果是要把限制改大。both server and client : side。 : : 64KB : desktop : URL