Several colleagues, and I have a problem in which the response from the ajax call returns some unexpected content. Instead of returning a simple JSON object with various properties, the value of result.responseText is the HTML markup of the 406 error common page, stating that the MIME type is not accepted by the browser.
The call is made like this:
$.ajax({ url: '/promociones/cincogratis/canjear-codigo-promocional', type: this.method, data: $(this).serialize(), success: function (result) { $('.promotion_banner .loader').hide(); $('.promotion_banner').html(result); }, error: function (result) { var obj = result.responseText; if (obj.isRedirect) { document.location = obj.redirectUrl; } else { $('.promotion_banner .loader').hide(); $(".error-wrapper").removeClass("hidden"); var generic_error = document.getElementById('generic_error').value; $(".error-wrapper p").html(generic_error); } }, beforeSend: function() { $('.promotion_banner .loader').show(); } });
The controller’s response to the call looks like this:
Response.StatusCode = (int)HttpStatusCode.NotAcceptable; // 406 return Json(new { errorMessage = LocalErrorMessages.Website_Promotions_FreeFiver_General_Problem, isRedirect = false } );
We expect result.responseText to contain key values for errorMessage and isRedirect, but theyre not exist.
It is worth noting that this code is multi-user, shared by the current application, and the other, where it works absolutely fine.
We believed:
- Setting IIS to display detailed answers about errors, and not on a special page for more detailed information - does not give us anything superfluous in solving the problem.
- Allow all types of call answering content
- Changing the culture of our site (currently es-ES)
- Various web.config settings
Has anyone had this problem?
dev'd source share