dongliao1948 2015-07-08 14:49
浏览 242

错误:413在C#WinForm应用程序中请求实体太大

I am trying to send JSON Object to Server for data synchronization. This JSON object contain non-synchronized images and their data.

Real problem is not with he JSON or the Synchronization code. But it is with the size of the Request i am sending to the server. if the size cross the limit 1.1MB then i Got this message

The remote server returned an error: (413) Request Entity Too Large.

Please Help me. It is pur C# application not the WCF application. Domain Hosting provider is Godady.com. Using Apache server and PHP script.

Every this is working fine for smaller size. but it give exception error when size cross 1.1MB.

Here is My Request Code.

public string SubmitData(string poststring)
    {
        string result ="false";

        if (poststring.ToLower() == "empty")
        {
            result = "empty";
            return result;
        }

        try
        {
            ASCIIEncoding encoding = new ASCIIEncoding();
            string postData = poststring;
            byte[] data = encoding.GetBytes(postData);


            WebRequest request = WebRequest.Create("http://blunor.com/dark/data.php");
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.Credentials = CredentialCache.DefaultCredentials;
            request.ContentLength = data.Length;

            Stream stream = request.GetRequestStream();
            showMessageBox(data.Length.ToString(), "Message", 1);
            stream.Write(data, 0, data.Length);
            stream.Close();

            WebResponse response = request.GetResponse();
            stream = response.GetResponseStream();

            StreamReader sr = new StreamReader(stream);

            // this block of code check if response is +ve or negtive..
            string res_num = sr.ReadToEnd();

                if (res_num == "1")
                {
                    result = "true";
                }
                else
                {
                    result = "false";
                }
            //block end here.....

            sr.Close();
            stream.Close();

            return result;


        }
        catch (Exception ex)
        {
            MessageBox.Show("Error : " + ex.Message);
        }
        return result;
    }

For Server php post_max_size = 128M and Upload_max_filesize = 32M

Please Help......

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c