我有一个控制器,它将传递数据以查看 Index.cshtml
public ActionResult Index()
{
var empId = @User.Identity.Name;
var empDetails = empRepository.GetEmployeeDetails(empId);
var emp = new UserViewModel {EmployeeDetail = empDetails};
return View(emp);
}
视图 Index.cshtml 的布局是 Partialview _Layout.cshtml
@model HRM.Areas.EmployeeDetails.Models.UserViewModel
@{
ViewBag.Title = "Index";
Layout = "~/Areas/EmployeeDetails/Views/Shared/_Layout.cshtml";
}
<div>Hello</div>
我想访问从控制器操作传递到_Layout.cshtml 中的Index.cshtml 的数据。
有没有办法做到这一点?