我在 C# 4.0 中有一个小应用程序。远程服务器是 Apache2。
我遇到错误问题:远程服务器返回错误:(414)当我使用 POST 方法向此处发送数据时,请求 URI 太大。
我尝试使用此代码连接到 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。你能帮助我吗?