I had a function in controller named Export
[HttpPost]
[ActionName("Export")]
public async Task<FileStreamResult> Export(int a)
{
var fileStream = new MemoryStream();
var contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
return new FileStreamResult(fileStream, contentType);
}
I called this function from the view using ajax.
$('#GetDetails').click(function () {
$.ajax({
url: '@Url.Action("Export", "ExportNow")',
type: 'POST',
data: {a:1},
success: function (result) {
alert('Success.');
},
error: function (result) {
alert('Failed to Export.');
}
});
});
how i can open the FileStreamResult returned from the Export function (download file). Anyone please help.