【问题标题】:The remote server returned an error: (414) Request-URI Too Large远程服务器返回错误:(414) Request-URI Too Large
【发布时间】: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。你能帮助我吗?

【问题讨论】:

    标签: c# apache


    【解决方案1】:

    我曾经遇到过类似的问题,我的解决方案是这里的第一个答案: How to Avoid Server Error 414 for Very Long QueryString Values 也许它可以帮助你处理很长的查询字符串?

    【讨论】:

    • 这对我没有帮助。我还是有这个问题
    【解决方案2】:

    有一个类似的问题,除了 POST 工作正常,但具有完全相同参数的第二个 POST 返回 414。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-15
      相关资源
      最近更新 更多