//Is called on page load. Get the next unanswered question from DB or displays user's score if all answered public ActionResult Index() { //initialize the viewmodel object that will be returned to the razor view QuestionAnswer question = new QuestionAnswer(); try { question.ShowNextQuestionOrScore(_context); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); question.isError = true; } return(View(question)); }