troubleshooting Question

Response.TransmitFile not opening Save dialog

Avatar of Hardus Lombaard
Hardus LombaardFlag for South Africa asked on
ASP.NETC#HTML.NET ProgrammingAngular
15 Comments2 Solutions1854 ViewsLast Modified:
Hi. I have a button that calls an Angular function that makes an http post call. Inside my C# a file is created on the server. I then want to download it to the client with Response.TransmitFile(), but it doesn't work.

<button style="width: 140px;" ng-click="Export()" class="btn btn-default btn-vk">EXPORT</button>

var request = $ + 'DistributionData/Export', { requestData: requestData });

System.Web.HttpResponse response1 = System.Web.HttpContext.Current.Response;
response1.AddHeader("Content-Disposition", "attachment; filename=hardus.xlsx");
response1.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

This code pretty much does nothing. No dialog. The file just lies on the server.
Mohit Vijay

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros