Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

POST method returns FileContentResult but save as dialog is not launched in browser

$
0
0

Hello,

  I've written a POST method in Web API project. 

This POST method looks like

[HttpPost]
        [ActionName("downloadfile")]
        public System.Web.Mvc.FileContentResult DownloadImportedFile(string id)
        {
            try
            {
               byte[] fileContent =  ... //some logic to get the file content into byte array
                var fileContentResult = new System.Web.Mvc.FileContentResult(Encoding.UTF8.GetBytes(fileContent, "text/xml");
                fileContentResult.FileDownloadName = "myFile.xml];
                return fileContentResult;
            }

}

On the client side, I'm using HTML and AngularJS. 

var data = {
                JobId: "This_Is_My_Id"
            };

$http.post(url, data, config);

The fileContentResult is properly populated with byte array and the POST method returns value perfectly. But on the browser side

save as dialog is not launched.

Please help.

Thanks,

Saswat


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>