I've the next controller with parameters: controlador, mostrarBorrados, listaFiltrosSeleccionados, cantRegistros and reportType.
[HttpGet]
public ActionResult GetReport(string controlador, bool mostrarBorrados, List<FiltroSeleccionado> listaFiltrosSeleccionados, int? cantRegistros, string reportType)
{
//...
return File(renderedBytes, mimeType);
}
And I call it with the next ajax code:
$.ajax({
url: '@Url.Action("GetReport", "Report")',
type: 'GET',
dataType: 'binary',
data: { controlador: "condIva", mostrarBorrados: mostrarBorrados,
listaFiltrosSeleccionados: listaFiltrosSeleccionados, cantRegistros : cantRegistros, reportType: "EXCELOPENXML" },
success: function (response) {
var url = URL.createObjectURL(response);
var $a = $('<a />', {
'href': url,
'download': 'descarga.xlsx',
'text': "click"
}).hide().appendTo("body")[0].click();
}});
The file is generated correctly, but the problem is with "listaFiltrosSeleccionados" parameters. It arrives "null", like the next image:
What am I doing wrong? I tried differents way but it doesn't work (I put HttpPost, used stringify, etc.)
Thanks!
listaFiltrosSeleccionados[0].someProperty=xx,listaFiltrosSeleccionados[0].anotherProperty=yy,listaFiltrosSeleccionados[1].someProperty=zzetc, which will almost certainly exceed to query string limit and throw an exception (apart from the really ugly query string)