Reputation: 420
I have a hyperlink that I added to my ASP.NET web form. Here is the code:
<asp:HyperLink ID="lnkDownloadG2" Visible="false" runat="server" NavigateUrl="~/Savefile/input_overwriteG2.txt" Target="_blank">Download</asp:HyperLink>
When I click on the hyperlink I want the file to download to downloads folder (or whatever folder is specified in browser settings). Instead it is opening in a new tab. How can I force the file to download instead of opening up in a new browser tab?
Upvotes: 1
Views: 4627
Reputation: 2344
Answer to your question might be in this StackOverflow article: how to force a download file prompt instead of displaying it in browser
For non HTML5 approahc you will have to trick the browser by changing the headers (from your app side or directly at server lever) see this article for more details: http://www.tipsandtricks-hq.com/forum/topic/force-a-file-to-download-instead-of-showing-up-in-the-browser
Upvotes: 2