我是用循环来调用的.不是马上出现,出现的时间不定...奇怪了string loginUrl = "http://192.168.1.101/DoServer.Class.php";
            Encoding encoding = Encoding.GetEncoding("UTF-8");            HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(loginUrl, parameters, null, null, encoding, null);
            //response.ti
            StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
            String retValue = sr.ReadToEnd();            sr.Close();            return retValue;System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
   at System.Net.HttpWebRequest.GetResponse()
   at WindowsEE.HttpWebResponseUtility.CreatePostHttpResponse(String url, IDictionary`2 parameters, Nullable`1 timeout, String userAgent, Encoding requestEncoding, CookieCollection cookies)
   at WindowsEE.MethodOption.common(IDictionary`2 parameters)
   at WindowsEE.Main.timer2_Tick(Object sender, EventArgs e)
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

解决方案 »

  1.   

    HttpWebResponseUtility对象在没有完成上次访问的时候,又进行下次操作,结果出错了。
      

  2.   

    我是用循环来调用的.不是马上出现,出现的时间不定...奇怪了
    问题出在这,你为什么要循环调用呢?来不及反应,肯定挂了。类似于ddos攻击,服务器受不了,就停止服务了。
      

  3.   

    那如何来使用多线程方式发送post
    也就是循环里面,判断当满足条件,就新建一个线程去提交数据,并且取得返回值.
    有例子最好
      

  4.   

    HttpWebRequest 设计成为 keepalive 看看
      

  5.   

    =true ???
     不是要长时间保持???  这是服务器主动断开的吧,你保持不了的吧
      

  6.   

    服务器端的问题。检查它有没有缺少 Flush、Close语句并且确实执行到这里。有时候甚至是服务器端抛出了异常(可惜有些程序员写的程序隐藏了异常,使得无法调试)。
      

  7.   

    你可以为Debug下的服务器端程序写个日志,每一个http请求处理过后服务程序是否执行到Response的输出流的Flush、Close语句,还是因为异常而崩溃了,都要记录在日志里。
      

  8.   

    对于通讯程序来说,遇到异常是常有的事情。因此这通常用UI层捕获异常就行了,例如这个错误抛出给
    System.Windows.Forms.Application.ThreadExceptionEventHandler 捕获,在界面上给用户一个友好提示,然后用户“知道了”之后程序就继续执行下去就好了。而如果是静默的、轮询的任务,你自己捕获异常然后过一会儿重新开始任务就行了。凡是涉及到互联网通讯的程序,都可能随时抛出异常。因此考虑到这个处理就行了。
      

  9.   

                request.KeepAlive = false;
                request.ProtocolVersion = HttpVersion.Version10;
      

  10.   

    试下System.Net.ServicePointManager.Expect100Continue=false;
      

  11.   

    是不是多线程调用了同一个对象的同一个方法.
    你在多线程里new这个对象,调用他的方法吧.避免多线程调用太频繁,服务器有链接时长限制