2012-08-06 156 views
0

我在C#4.0中有小应用程序。远程服务器是Apache2。远程服务器返回错误:(414)请求URI太大

我有错误的问题: 远程服务器返回错误:(414)请求URI太大,当我使用POST方法发送数据时。

我尝试使用此代码连接到的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。你可以帮我吗?

回答

0

也有类似的问题,但POST是工作,但完全相同的参数第二POST返回414

设置request.KeepAlive = false;解决了这个问题

相关问题