所以我正在制作一个程序,您可以在其中输入一些信息。一部分信息需要大量文本,我们说的是 100 多个字符。我发现当数据很大时,它根本不会发送数据。这是我正在使用的代码:
public void HttpPost(string URI, string Parameters)
{
// this is what we are sending
string post_data = Parameters;
// this is where we will send it
string uri = URI;
// create a request
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
// turn our request string into a byte stream
byte[] postBytes = Encoding.ASCII.GetBytes(post_data);
// this is important - make sure you specify type this way
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
// now send it
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
}
然后我像这样调用该方法:
HttpPost(url, "data=" + accum + "&pass=HRS");
'accum' 是我发送的大量数据。如果我发送少量数据,此方法有效。但是当它很大时,它不会发送。有没有办法向我网站上的 .php 页面发送超过 100 多个字符的发布请求?
谢谢。