mvc data size acception

ITsolutionWizard
ITsolutionWizard used Ask the Experts™
on
i have the following codes, and everything is working except the outhtml's size is too big but i do not know how big.
so I added some settings on webconfig but it is till not working.
Can you share with me whatelse I need to do to max the size of accepting data size?
[HttpPost]
        public JsonResult GetAgingReport(string invoicestartandenddate, string receiptstartandenddate, string chargecode)
        {
             
            Domain.Accounting.Report r = new Domain.Accounting.Report();             
            r.invoicestartdate = invoicestartdate;
            r.invoiceendate = invoiceenddate;
            r.receiptstartdate = receiptstartdate;
            r.receiptenddate = receiptenddate;
            r.chargecode = chargecode;
    
            MasterController.ServiceAccounting sa = new MasterController.ServiceAccounting();
            List<Domain.Accounting.Report> agingInDetail= sa.AgingInDetails(r);
            string returnStrInHTML = sa.AgingInDetailsInHTML(agingInDetail);
       
             r.outputHTML = returnStrInHTML;
            return Json(r, JsonRequestBehavior.AllowGet);
        }

Open in new window

  $.ajax({
                url: "/Accounting/GetAgingReport",
                datatype: "text",
                data:
                {
                    'invoicestartandenddate': invoicestartandenddatevalue,
                    'receiptstartandenddate': depositstartandenddatevalue,                   
                    'chargecode': chargecodevalue
                },
                type: "POST",
                success: function (data) {
                    var id = data.outputHTML;
                    alert("Success");
                         
                },
                error: function (error) {
                    alert("Error " + error);

                }
            }); 

Open in new window

 <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.6.1"/>
    <httpRuntime targetFramework="4.6.1" executionTimeout="100000" maxRequestLength="214748364" />
  </system.web>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="2147483647" />
      </webServices>
    </scripting>
  </system.web.extensions>
  <system.webServer>
     <security>
      <requestFiltering>
        <requestLimits  maxAllowedContentLength="2147483647"  />
      </requestFiltering>
    </security>
  </system.webServer>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
anyone can help?

Author

Commented:
any one here ?
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
What is the maximum size you are trying to post? any approximation?
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Author

Commented:
I don't the size. just tell me what else I need to do on the setting

Author

Commented:
any helps?

Author

Commented:
any helps?
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Are you getting any errors when you try to upload the file? If yes, please paste the error content here, you can remove any sensitive information from the error.

Author

Commented:
not upload it is Json response
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Did you try to debug it on server side? Or it fails before you hit the breakpoint? What do you get in JsonResponse?

Author

Commented:
all i see object object alert in js.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
But that would mean
The call was successful. If there was an error you would see alert("Error " + error);
                    var id = data.outputHTML;
                    alert("Success");
 

Open in new window


Also you have set the size to 2147483647, any specific reason/calculations behind this number?
Also 214748364 would mean size of 2GB, which I think is way too high for a Report. Maybe you need to tweak this number as well.

As long as you are not getting an error, I suggest you look in to your server side code why it is not able to process the message.

Author

Commented:
i did review the source code behind.and I actually put the exact same codes on aspx / c# page, and it is working and without any errors regardless of any sizes.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Did you change the web.config's 2147483647 value to 214748364 or even that was not needed?

Author

Commented:
I post the web config codes already when i post this question.

 <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.6.1"/>
    <httpRuntime targetFramework="4.6.1" executionTimeout="100000" maxRequestLength="214748364" />
  </system.web>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="2147483647" />
      </webServices>
    </scripting>
  </system.web.extensions>
  <system.webServer>
     <security>
      <requestFiltering>
        <requestLimits  maxAllowedContentLength="2147483647"  />
      </requestFiltering>
    </security>
  </system.webServer>

Open in new window

Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
I know you posted web.config, I just wanted to check if you changed the values or not. It seems you did not.

When you run the page and upload a large file, do you see an alert with "Success" in it?

Also can you check what are you getting from the server side method by putting a debugger and watching the value of data in browser console?
success: function (data) {
debugger;
                    var id = data.outputHTML;
                    alert("Success");
                },

Open in new window

Author

Commented:
I change the number and add debugger there.
The response is no change.

Author

Commented:
any progress?
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
debugger is used on client side script to check if it stops, have you tried debugging the JavaScript using Developer Tools of the browser?

Also do you see any alert message?

Author

Commented:
hi chinmay, i am not sure you refer to.
Chief Technology Ninja
Distinguished Expert 2018
Commented:
Originally, you posted
  $.ajax({
                url: "/Accounting/GetAgingReport",
                datatype: "text",
                data:
                {
                    'invoicestartandenddate': invoicestartandenddatevalue,
                    'receiptstartandenddate': depositstartandenddatevalue,                   
                    'chargecode': chargecodevalue
                },
                type: "POST",
                success: function (data) {
                    var id = data.outputHTML;
                    alert("Success");
                         
                },
                error: function (error) {
                    alert("Error " + error);

                }
            }); 

Open in new window


I suggested you change it to:
  $.ajax({
                url: "/Accounting/GetAgingReport",
                datatype: "text",
                data:
                {
                    'invoicestartandenddate': invoicestartandenddatevalue,
                    'receiptstartandenddate': depositstartandenddatevalue,                   
                    'chargecode': chargecodevalue
                },
                type: "POST",
                success: function (data) {
debugger;
                    var id = data.outputHTML;
                    alert("Success");
                         
                },
                error: function (error) {
                    alert("Error " + error);

                }
            }); 

Open in new window


the "deubbger;" keyword will stop executing the code and let you see what is happening on the client side. As you said, the code works fine so I wanted to check what response we are getting from server?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial