我的應用必須下載某個文件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請求/響應。 –