I have two views: Product/List, which displays a list of products, and Product/Details/{id}, which displays the details of the product of the given Id.
Every time when a user clicks on a product item on the Product/List view to go to the Product/Details/{id} view, it takes about 4 seconds. I have been researching what takes so long and would like to make it a little faster.
So, I updated my action method Details as follows, assuming the database call in the constructor ProductDetailsViewModel(int) is causing the delay.
[Route("Product/Details/{id}")]
public ActionResult Details(int? id) {
Stopwatch watch = new Stopwatch();
watch.Start();
var viewModel = new ProductDetailsViewModel(id);
watch.Stop();
int duration = watch.Elapsed.Milliseconds;
return View(viewModel);
}
But, it is not. duration
is only about 500 to 600 milliseconds.
I googled and did something like that provided by Nick at http://nickberardi.com/timing-the-execution-time-of-your-mvc-actions/
And I consistently get about 4 seconds for the load time of Product/Details/{id}. See the screenshot (chrome dev tools) below.
I am little puzzled. What else could be causing the execution of the action method to take this long? Any idea? Thanks.
UPDATED WITH Glimpse.Mvc5 timeline: