Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WebRequestPostLong值?_C# - Fatal编程技术网

C# WebRequestPostLong值?

C# WebRequestPostLong值?,c#,C#,我有一个300行的字符串,有没有办法做到这一点? 这是我的代码,目前正在处理数量有限的短信: WebRequest req = (HttpWebRequest)WebRequest.Create( "http://thisisurl/test.php?ad=test&f=" + information_data); req.Method = "POST"; WebResponse res = req.GetResponse(); 我现在就解释你的问题,然后继续,最后给你一个可能

我有一个300行的字符串,有没有办法做到这一点? 这是我的代码,目前正在处理数量有限的短信:

WebRequest req = (HttpWebRequest)WebRequest.Create(
    "http://thisisurl/test.php?ad=test&f=" + information_data);
req.Method = "POST";
WebResponse res = req.GetResponse();

我现在就解释你的问题,然后继续,最后给你一个可能的解决方案

您达到了url长度/查询参数长度的字符限制。IE将其限制在2083以下

您提供的数据应该在http请求主体中发送,而不是URL参数

Post请求通常以以下格式完成(链接中的代码)

如果要改用WebRequest类,则此线程应具有足够的信息:

您没有使用f参数发布数据,是吗?f参数用于发布数据data@user3915278这不是邮寄。过帐意味着将数据写入Http消息体。(顺便说一句:url有长度限制。这就是为什么不能“发布”长数据)理想的解决方案是将数据发布为字节数组。检查这个
using (var wb = new WebClient())
{
    var data = new NameValueCollection();
    data["username"] = "myUser";
    data["password"] = "myPassword";

    var response = wb.UploadValues(url, "POST", data);
}