111,129
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
namespace TestCon
{
static class BillInfo
{
public static string BillInfo_Post_Get(string Post_String,string Post_Data) {
try {
string s_Connection_String = Post_String;
HttpWebRequest BillInfo_Request = (HttpWebRequest)WebRequest.Create(s_Connection_String);
BillInfo_Request.Method = "POST";
BillInfo_Request.ContentType = "application/x-www-form-urlencoded";
BillInfo_Request.ContentLength = s_Connection_String.Length;
BillInfo_Request.Timeout = 20000;
Stream BillInfo_Stream = BillInfo_Request.GetRequestStream();
BillInfo_Stream.Write(Encoding.UTF8.GetBytes(Post_Data), 0, Encoding.UTF8.GetBytes(Post_Data).Length);
HttpWebResponse BillInfo_Response = (HttpWebResponse)BillInfo_Request.GetResponse();
StreamReader BillInfo_Reader = new StreamReader(BillInfo_Response.GetResponseStream(), Encoding.UTF8);
return BillInfo_Reader.ReadToEnd();
}
catch (System.Exception ex) {
Console.WriteLine(ex);
Console.ReadLine();
return "";
}
}
}
}
问题解决了= =但是我还是很好奇为什么不能设置这个,我设置的长度和我的字段长度是一致的呀 不要设置ContentLength
不要设置ContentLength