远程服务器返回错误:(414)请求URI太大



我在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。你能帮我吗?

我曾经遇到过类似的问题,我的解决方案是这里的第一个答案:如何避免超长QueryString值的服务器错误414也许它可以帮助您处理很长的查询字符串?

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

设置request.KeepAlive = false;解决了

问题

最新更新