I am trying to download or at least open a generated csv file via ajax. I have managed to log the output and everything comes out fine. Is it possible to do it via ajax or must I try it another way? Controller
[HttpPost]
public FileResult GenerateEventLogsReport([FromBody]GenericReportDateViewModel Input)
{
    var report = eventLogsData.Report(Input.StartDate, Input.EndDate);
    var sb = new StringBuilder();
    foreach(var item in report)
    {
        sb.AppendLine(item.Id + "," + item.Identity + "," + item.Level + "," + item.Logger + "," + item.Message + "," + item.TimeStamp + "," + item.Action);
    }
    return File(new UTF8Encoding().GetBytes(sb.ToString()),"text/csv","EventLogs_"+ Input.StartDate +"_to_"+ Input.EndDate +".csv");
}
AJAX
var event_form_data = {
    "StartDate": $("#eventStartDate").val(),
    "EndDate": $("#eventEndDate").val(),
};
$.ajax({
    url: "@Url.Action("GenerateEventLogsReport", @ViewContext.RouteData.Values["controller"].ToString())",
    method: "POST",
    data: JSON.stringify(event_form_data),
    contentType: "application/json",
    success: function (result) {
        console.log(result);
        window.open("data:application/csv", result, "_blank");
    },
    error: function (error) {
        console.log(error);
    }
});
 
    