【发布时间】:2012-08-06 13:27:31
【问题描述】:
我在 C# 4.0 中有一个小型应用程序。远程服务器是 Apache2。
我有错误的问题: 远程服务器返回错误:(414) Request-URI Too Large when I send here data using POST method.
我尝试使用此代码连接到 apache2:
String mainAddressWebApi = "http://myremoteserver.domain.pl/alias/index.php";
private HttpWebRequest request;
request = (HttpWebRequest)WebRequest.Create(this.mainAddressWebApi);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Referer = "http://stackoverflow.com";
request.UserAgent = "Mozilla/5.0";
request.CookieContainer = cookie;
NetworkCredential credentials = new NetworkCredential("login", "password");
this.request.Credentials = credentials;
Byte[] byteData = utf8.GetBytes(data);
request.ContentLength = byteData.Length;
Stream newstream = request.GetRequestStream();
newstream.Write(byteData, 0, byteData.Length);
newstream.Close();
this.response = (HttpWebResponse)request.GetResponse(); //I get error here
数据应使用 POST 发送。数据最大为 2mb。你能帮助我吗?
【问题讨论】: