描述:某次更新程序,需要給測試員MM測試,之前都是正常的,更新后給MM測試就報異常System.Net.WebException 無法從傳輸連接讀取數(shù)據(jù):連接已關(guān)閉 -------> System.IO.IOException:
無法從傳輸連接中讀取數(shù)據(jù):你的主機中的軟件中止了一個已建立的連接。
我在控制臺應用程序中有這個代碼,它運行在一個循環(huán)中
try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(search); request.Headers.Add("Accept-Language","de-DE"); request.Method = "GET"; request.Accept = "text/html"; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (StreamReader reader = new StreamReader(response.GetResponseStream(),Encoding.ASCII)) { string html = reader.ReadToEnd(); FindForMatch(html,url); } } } catch (Exception ex) { throw new Exception(ex.Message); }
Unable to read data from the transport connection: The connection was closed
錯誤.任何想法為什么會這樣?感謝名單..
加入后
request.KeepAlive = false; request.ProtocolVersion = HttpVersion.Version10;
它工作正常..
我發(fā)現(xiàn)它形成這個博文
WebRequest and Unable to read data from the transport connection Error
以上為你收集整理的c# – 無法從傳輸連接讀取數(shù)據(jù):控制臺應用程序中的連接已關(guān)閉錯誤全部內(nèi)容,希望文章能夠幫你解決c# – 無法從傳輸連接讀取數(shù)據(jù):控制臺應用程序中的連接已關(guān)閉錯誤所遇到的程序開發(fā)問題。
如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答!! 點擊進入論壇