Now in the controller, something like this code:
[System.Web.Http.HttpGet] public HttpResponseMessage exportCSV() { string csvString = model.getAllInCSV(); var response = Request.CreateResponse(); response.StatusCode = HttpStatusCode.OK; response.Content = new StringContent(csvString, Encoding.GetEncoding("WINDOWS-1251")); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "foo.csv" }; return response; } csvString is generated in about a couple of minutes, is there a way to immediately upload a file to a user? because Now if the user clicks on the download link, and within the time until the file is formed, it will go to another page of the download, respectively, will not happen.