Mvc Ajax Call To Download File

Mvc Ajax Call To Download File Rating: 7,6/10 3737 reviews

Introduction If we use the jquery ajax api, it an asynchronism by default, most of time this is what we need, but in some special case we will want to make a synchronized ajax call. Using the code For make a synchronized ajax call, we can use ‘async: false‘ setting, it will disable async for handle the return value.

Call

Download File Via Ajax

@OmarPadilla, you cannot download files using AJAX to the client. But even if that was possible you would have wasted exactly the same quantity of bandwidth as if you used a direct link to download the file. The simple reason for that is that in both cases you are calling the same endpoint on the server which is returning the same file. And don't be fooled into thinking that if you don't use AJAX, the current page will reload. There are no additional requests other than the one to the controller action that will stream the file.–Feb 7 '14 at 14:04.