Create and download the file with Ajax call in ASP. Copy Code. Member Jul Majid Qafouri Jan Ghouse M 1-Jan MarceloGuy Sep Elvin Acevedo Jun Go to top. Layout: fixed fluid. Web Developer. Hong Kong. First Prev Next. Very helpful. Introduced me to 3 new concepts I did not know about: 1 separating the request for file creation from the further request to download the file; 2 BlockUI jQuery plugin; 3 ActionFitlerAttribute. The download attribute was added to the anchor element in HTML 5.
It informs the browser to download the requested URL instead of navigating to it. You can also specify an optional value for the download attribute to be used as a file name once it is downloaded.
If the value is not provided, the original filename is used. As you can see above, the download attribute is the easiest way to download a file on the browser. However, the download attribute only works in modern browsers. Internet Explorer does not support it. The idea is to programmatically create an anchor link, and then trigger the click event. This method is especially helpful for dynamically generated file URLs.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 6 years, 8 months ago. Active 6 years, 8 months ago. Viewed 7k times. I am open to ideas! Improve this question. You can do it by AJAX.
You have done it wrong if it's messy, but we can't tell you what you've done wrong until you provider your code. Please edit it into your question. Are you using a JsonResult , it should be incredibly easy. I seem to remember there is some problem with attempting to download a file with ajax. I mean you dont want your javascript getting the file do you. I have modified my post. I have tried numerous things with this being the latest The return from the Controller gets lost in the Ether Show 1 more comment.
Active Oldest Votes. View Part I added mine to index. Instance; instance. ToString ; instance. ToString ; this. Add cookie ; return token. Instance; if this. Cookies["CookieToken"]; if instance.
AddDays -1 ; this.
0コメント