If you are using ASP.NET Core MVC, the answers above are ever so slightly altered...
In my action method (which returns async Task<JsonResult>
) I add the line (anywhere before the return statement):
Response.Headers.Add("Content-Disposition", $"attachment; filename={myFileName}");