0

I'm trying to serialize a knockout object and pass it into a JSON property called multipleCharge.

This is the ajax code to send data though Get method to a mvc controller

        $.ajax({
            url: _url,
            type: 'GET',
            //data: { multipleCharge: ko.mapping.toJS(_vm)},
            data: { multipleCharge : { AccountId : 2 } },
            dataType: 'json'});

And this is the method

[HttpGet]
public HttpResponseMessage GetSalesInvoiceMultipleCharge
    ([FromUri]MultipleChargeDto multipleCharge)
{
    ...
}

Please, note that the ajax method has a comment line. Using the hardcoded line, it works, multipleCharge object is not null, but if I uncomment the another line, it's a bad request in my browser.

Look at this.

enter image description here

enter image description here

Any idea about what's happening. Using the Chrome console, it looks ok; so I can't identify the error.

tereško
  • 58,060
  • 25
  • 98
  • 150
Darf Zon
  • 6,268
  • 20
  • 90
  • 149

1 Answers1

0

It is may be IIS problems with very long URL.
See this Issue with URL length in IIS7 (Windows Server 2008) question and related answers.
Also see this http://www.iis.net/configreference/system.webserver/security/requestfiltering documentation.
You could try to solve this problem by editing web.config. But also you could use POST method instead of GET and send your data in request body.

Community
  • 1
  • 1
Ivan.Srb
  • 1,851
  • 1
  • 14
  • 10