I am trying to download a file by clicking a button but instead of getting my file as "myFile.csv" the file that returns is called "download" without any extension. I have tried the following solution as well Download text/csv content as files from server in Angular
This is server response
            var result = engine.WriteString(recs);
            response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(Encoding.UTF8.GetBytes(result)) };
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = String.Format("TVF_Export_{0}.csv", DateTime.Now.ToShortDateString())
            };
            return response;
Client code
        $http.post(url, filters).success(function (data, status, headers, config) {
        console.log(data);
        var hiddenElement = document.createElement('a');
        hiddenElement.href = 'data:attachment/csv,' + encodeURI(data);
        hiddenElement.target = '_blank';
        hiddenElement.download = 'myFile.csv';
        hiddenElement.click();
    }).error(function (data, status, headers, config) {
        console.log('[DEBUG] error ' + data);
    });
 
     
    