public IActionResult Details()
 {
     Models.Student model = studentRepository.GetStudent(2);
     ViewModels.HomeDetailsViewModel homeDetailsViewModel = new ViewModels.HomeDetailsViewModel()
     {
         Student   = model,
         PageTitle = "Student"
     };
     //ViewData["PageTitle"]="Student";
     //ViewData["Student"]=model;
     return(View(homeDetailsViewModel));
 }
Example #2
0
        //[Route("Details/{id?}")]//属性路由
        public IActionResult Details(int id = 1)
        {
            Student model = _studentRespository.GetStudent(id);

            ViewModels.HomeDetailsViewModel homeDetailsViewModel = new ViewModels.HomeDetailsViewModel()
            {
                Student   = model,
                PageTitle = "学生详细信息"
            };
            //ViewData["PageTitle"] = "Student Details";//viewdata运行时动态解析,弱类型
            //ViewData["Student"] = model;

            //ViewBag.PageTitle = "学习详情";//本身是动态类型 弱类型
            //ViewBag.Student = model;
            //  return View();

            return(View(homeDetailsViewModel));//相对路径不需要扩展名  根路径"~/MyViews/Test.cshtml"
        }