我的应用必须下载某个文件here is the url。这个应用程序在提供商端最近发生的变化之后可以正常工作多年。我得到'底层连接已关闭:发送时发生意外错误。WebRequest:底层连接已关闭
我已阅读所有相关的信息在网络中,但没有建议的修复程序适用于我。
重要说明:Net Framework 4.6的代码工作正常,但我需要它与3.5一起工作。
任何想法?
下面是代码:
var url = new Uri(@"http://www.ezv.admin.ch/pdf_linker.php?doc=edecReceiptResponse_stylesheet_v_3_0");
var request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = false;
request.AllowAutoRedirect = true;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
request.ProtocolVersion = HttpVersion.Version10;
更新:堆栈:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
一个以上更新:使用Fiddler检查连接到http 小号该应用和比较响应收到净4.6(工程)净3.5(失败):
- 4.6接收两个应答,5670个+ 664785字节
- 3.5还接收两个响应,7个字节每个
要么'www.ezv.admin。ch'关闭连接或者您有通信问题(网络问题/防火墙)。 – bradbury9
显示其堆栈跟踪 –
请显示来自Fiddler或Wireshark的HTTP请求/响应。 –