Is there a way to detect when ASP.NET returns a file? I recently added code to my project to show a loading gif whenever a button is pressed.
<script type="text/javascript>
jQuery('.btn').click(function() {
jQuery".loader").show();
});
I have successfully set up a loader div and applied CSS to display the GIF. Everything works perfectly when the button triggers controller code that uses RedirectToAction. However, an issue arises when the controller returns a File(). With RedirectToAction, the page reloads, causing the loading gif to disappear. But with a file return, the loading gif remains on the screen.
Does anyone have any suggestions on how to hide the gif when a file is returned or perhaps a more effective way to manage the loading gif overall? I am open to restructuring my approach, so any advice would be appreciated.