When is it more appropriate to use asynchronous calls from the view to get data vs prepopulating it server-side when creating the instance of the viewmodel?

For instance, if my view has some dropdown menus that need to be loaded with values for the user. When might it be better to add List to the viewmodel vs making an ajax call on $(document).ready.

Obviously, one time it may be preferred, is when I'm not the authority on the list of items in the dropdown (i.e. making a call to another web api).

Outside of that, what is the right approach here? I feel like populating these dropdowns in the controller is too bulky.

1 Answer 1


When you cant know in advance what the data will be and the total dataset is too large or dynamic to load and select from on the client.

You are attempting to give the user the best experience, which normally (after 'working') means 'fastest'

  1. A Single drop down with a static list.

The fastest solution is to populate the drop down server side.

  1. Two static drop downs, the second being filtered by the first selection

The fastest solution for small datasets is to populate both lists server side and do the filtering client side without an ajax call.

  1. Two static drop downs when the second is filtered by the first but the total list is large

In this case the time to download the entire list will be longer than the time to download the filtered list + ajax call

  1. Where the data changes dynamically while you are on the page.

Here we must use ajax or refresh the entire page

  • +1. Fewer HTTP requests laying around is better for everyone.
    – Machado
    Commented Mar 16, 2018 at 13:59
  • Thanks, that helps. I've just been second-guessing myself because of how much I've been focusing on minimizing controller action code. I've made the decision to continue populating the viewmodel properties server-side, but I've abstracted the code that does it into some private methods. That helps clean it up a little. Commented Mar 16, 2018 at 19:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.