111,128
社区成员
发帖
与我相关
我的任务
分享private void DeleteLesson(string kch)
{
string url = "省略网址";
string postData = "kch=“ + kch + ”&kxh=1001&xh=&uid=41356032";
byte[] byteResquest = Encoding.GetEncoding("gb2312").GetBytes(postData);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.ContentLength = postData.Length;
MessageBox.Show(postData.Length.ToString()); //下面有弹窗
MessageBox.Show(byteResquest.Length.ToString()); //下面有弹窗
req.CookieContainer = Whole.requestCookie; //cookie
req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
req.KeepAlive = true;
req.Method = WebRequestMethods.Http.Post;
Stream stream;
stream = req.GetRequestStream();
stream.Write(byteResquest, 0, byteResquest.Length);
stream.Close();
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
string htmlCharset = "utf-8";
Encoding htmlEncoding = Encoding.GetEncoding(htmlCharset);
StreamReader sr = new StreamReader(rep.GetResponseStream(), htmlEncoding);
string repHtml = sr.ReadToEnd();
}


有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。
************** 异常文本 **************
System.Net.ProtocolViolationException: 写入流的字节超出指定的 Content-Length 字节大小。
在 System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
在 System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
在 TGR.Choose.PostLesson(String id)
在 TGR.Choose.DeleteLesson(String kch)
在 TGR.Choose.LessonList_MouseDoubleClick(Object sender, MouseEventArgs e)
在 System.Windows.Forms.ListBox.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************