0

When the size of the array is less then I am able to call the action in the controller. If array size increases then I am not able to call the action.

In the code vendorPackage is an array whose size is causing the issue.

var data = {
  vendorData: vendorPackage,
  mopSystemNumber: mopSystemNumber
};

$.ajax({
  url: '/MOP/SomeActionName',
  data: data,
  async: false,
  type: 'post',
  success: function(result) {},
  error: function(xhr, ajaxOptions, error) {}
});

This is Action:

public void SomeActionName(List<Model.VendorData> vendorData, List<Model.VendorData> vendorData2, int mopSystemNumber)
{
  try
  {
    mopServiceAgent.PostVendorDetails(vendorData, mopSystemNumber, dt, userID);
  }
  catch (Exception ex)
  {
    utilityServiceAgent.LogExceptionMessageHandler(ex.Message, "MOPController-PostVendorDetails", dt, userID);
  }
}
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • 1
    Firstly remove `async: false`. It's terrible practice and the browser will be showing you a warning in the console telling you not to use it. With regard to the issue, it's impossible to say without seeing an error that's raised. However ASP.Net does have a default request limit size set to 2Mb - although how you've ended up with a 2Mb array on the client side would be a separate issue. Try increasing that limit. Exactly how you do it will depend on your configuration. Try just googling 'asp.net core maxrequestlength' – Rory McCrossan Jun 30 '20 at 11:55

1 Answers1

0

To increase the request size limit, you need different configuration based on your server.

See this artical:

http://www.binaryintellect.net/articles/612cf2d1-5b3d-40eb-a5ff-924005955a62.aspx#:~:text=to%20know%20more.-,Upload%20Large%20Files%20in%20ASP.NET%20Core,of%20additions%20to%20your%20code.

And a similiar question:

Asp.net Core 2.0 RequestSizeLimit attribute not working

mj1313
  • 7,930
  • 2
  • 12
  • 32