接收时发生意外错误

接收时发生意外错误

本文介绍了底层连接已关闭:接收时发生意外错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好。 我再次发布同样的问题。因为我没有得到我之前的问题的任何答复。 我正在处理一个应用程序。它是一个在.net 2.0中开发的窗口应用程序 现在的问题是,当我运行我的应用程序并向另一个应用程序发送请求时,它成功发送但我得到问题时,我收到响应它告诉我错误和错误是 基础连接已关闭:接收时发生意外错误。 /> 这是我的代码Hello everyoneI am posting the same question again. Because i did not get any reply from my previous question.I am working on an application. Its a window application which developed in .net 2.0Now the problem is this that when ever i run my application and i send a request to another application its send successfully but i get the problem when i get the response its show me the error and the error is The underlying connection was closed: An unexpected error occurred on a receive.here is my codepublic string tm4b(string sURL, bool bEscapeURL, string sPostData){sURL = sURL.Trim();while (sURL.IndexOf(" ") > 0){sURL = sURL.Replace(" ", " ");}System.Text.StringBuilder sb = new System.Text.StringBuilder();string stmp = string.Empty;Uri httpUri = new Uri(sURL, bEscapeURL);try{System.Text.ASCIIEncoding byteConverter = new System.Text.ASCIIEncoding();byte[] byte1 = byteConverter.GetBytes(sPostData);System.Net.HttpWebRequest hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(httpUri);hwRequest.ContentType = "application/x-www-form-urlencoded";hwRequest.Method = "POST";hwRequest.ContentLength = sPostData.Length; ;System.IO.Stream PostStream = hwRequest.GetRequestStream();PostStream.Write(byte1, 0, byte1.Length);System.Net.HttpWebResponse hwResponse = (System.Net.HttpWebResponse)hwRequest.GetResponse();System.IO.StreamReader sRead = new System.IO.StreamReader(hwResponse.GetResponseStream(),System.Text.Encoding.ASCII);if ((stmp = sRead.ReadLine()) != null){sb.Append(stmp + "");}PostStream.Close();sRead.Close();return sb.ToString();}catch (Exception ex){return "error";}return "Request Error";} 但它只给一个网址带来这个错误并为他人的网址运作良好 请检查代码和错误,请告诉我我必须做什么 i尝试了所有的逻辑我可以使用但没有得到任何好结果 所以专家请帮助我But its give me this error for only one url and for anothers url its working wellPlease check the code and error and please tell me what i have to doi tried all the logics that i can use but did not get any good resultsSo experts please help me推荐答案<system.net><settings><httpwebrequest useunsafeheaderparsing="true" /></settings></system.net> 它正在工作但当我退出fidler然后它给我错误是什么原因请告诉我Its working then but when i exit the fidler then its give me error what is the reason please tell me 这篇关于底层连接已关闭:接收时发生意外错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 11:56