0

I have HomeController which loads data to model from SQL DB.

Before the:

public ActionResult Index()
    {
        return View(_homePageViewModel);
    }

is hit, the data is loaded to

_homePageViewModel

and when it is ready the Razor Page is being loaded.

I have managed to show Loading GIF while Razor Page's content is being loaded, but there is some time before it that nothing is shown, it's when the HomeController's main constructor loads data from DB.

I need to show progress bar that will go from 0% to 100% while loading data from the DB.

I don't know how to achieve as the Index Page is not loaded yet.

Do I need to load loader page before the Index is rendered? Just to cover the time HomeController finishes it's work?

1 Answer 1

1

You need to create a "loader page", as you call it, that uses AJAX to update its contents. However there is no way to measure and show the % in the page: there isn't something like a "db query completion percentage" that you can use.

The loader page could:

  • show some kind of spinner GIF
  • use an AJAX call to
    • get the relevant data (uisng web API) and render the HTML with javascript
    • get a partial page (using MVC), and include it in the loader page DOM
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.