Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:09:09+00:00 2026-06-09T07:09:09+00:00

My application has been implemeted using MVC 3, .net. I am trying to generate

  • 0

My application has been implemeted using MVC 3, .net.
I am trying to generate an excel file at the click of a button.
The call to the controller action is made using Ajax.
My main problem is: During the file generation i am trying to display an image on the screen to let the user know of the ingoing operation. I can very well display the image but i cannot hide it after the operation is completed. The codei am using is :

Javascript code:

$("input.DownloadExcelReport").click(function (e) {
   e.preventDefault();
   var parameter = -- code to fetch parameter value;
   var outputViewUrl = (the url is created here);
   showLoading(); -- This function displays the image
   window.location.href = outputViewUrl;
});

Controller Action code:

public ActionResult DownExcelReportForAssortment(Guid parameter)   
{

       try
       {

           //the contents for the file generation are fetched here..   
           // Write contents to excel file
           if (memoryStream != null)
           {
                var documentName = "Report.xls";
                byte[] byteArrary = memoryStream.ToArray();
                return File(byteArrary, "application/vnd.ms-excel", documentName);
           }
       }
       catch (Exception ex)
       {
           LogManager.LogException(ex);
       }
}

I do not return a Json result to the calling javascript method where i can write the code to hide the image.
I am returning a file which can be saved by the user and the action is completed.

Can somone please suggect/help me of how can i hide the image once the file generation operation is complete?

Appreciate the help…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:09:10+00:00Added an answer on June 9, 2026 at 7:09 am

    You may checkout the following article and put this into action. So we start by defining a controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    
        public ActionResult DownExcelReportForAssortment(Guid parameter, string tokenId)
        {
            // Simulate some heavy work to fetch the report
            Thread.Sleep(5000);
    
            // we fake it
            byte[] byteArray = System.IO.File.ReadAllBytes(@"c:\test.xls");
    
            var cookie = new HttpCookie("fileDownloadToken", tokenId);
            Response.AppendCookie(cookie);
    
            return File(byteArray, "application/vnd.ms-excel", "report.xls");
        }
    }
    

    and in the view:

    @Html.ActionLink(
        "download report",
        "DownExcelReportForAssortment",
        "Home",
        new { parameter = Guid.NewGuid(), tokenId = "__token__" },
        new { @class = "download" }
    )
    

    Now the last step is to include the jquery.cookie plugin:

    <script type="text/javascript" src="@Url.Content("~/scripts/jquery.cookie.js")"></script>
    

    and write a script to subscribe to the click event of the anchor and track the download progress:

    $(function () {
        var fileDownloadCheckTimer;
    
        $('.download').click(function () {
            var token = new Date().getTime();
            $(this).attr('href', function () {
                return this.href.replace('__token__', token);
            });
    
            // Show the download spinner
            $('body').append('<span id="progress">Downloading ...</span>');
    
            // Start polling for the cookie
            fileDownloadCheckTimer = window.setInterval(function () {
                var cookieValue = $.cookie('fileDownloadToken');
                if (cookieValue == token) {
                    window.clearInterval(fileDownloadCheckTimer);
                    $.cookie('fileDownloadToken', null);
    
                    // Hide the download spinner
                    $('#progress').remove();
                }
            }, 1000);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an mvc application that has been coded to use Windows authentication and
I’m working on an application which has been designed using n-tire application architecture .The
I have a code base that has been used as an ASP.Net web application.
What's the best way to tell my application that the file has been modified
I'm writing a new asp.net mvc application and I've been toying with the idea
In our application we have implemented role-based forms authentication. This has been handled using
I have a large 1 page ASP.Net application. Much of this application has been
The application has been put in iCloud since the beginning, so I have the
in the application simplexml has been converting an rss feed to an object and
My company has a ClickOnce application that has been in use with our customers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.