I am passing a list to my controller to generate an Excel file that need to be downloaded by user. The list am passing can be upto 10000 records
Here is my controller method
[HttpPost]
public FileResult Result(List<List> Content)
{
var stream = new MemoryStream();
var serializer = new XmlSerializer(typeof(List<Content>));
var data = Transformer.TransformToExcelFormat(Content);
//We turn it into an XML and save it in the memory
serializer.Serialize(stream, data);
stream.Position = 0;
//We return the XML from the memory as a .xls file
return File(stream, "application/vnd.ms-excel", "Template.xls");
}
Here is my java script
var Content = { "Content": ItemList() };
var pack = ko.toJSON(Content);
$.ajax({
url: baseUrl + '/Client/Result',
type: "POST",
datatype: "json",
data: pack,
contentType: 'application/json; charset=utf-8',
success: function (data) {
// Just wondering how to handle success result.
}
});
I will appreciate suggestion that will lead to success.
Thanks.