我试图在这里创建一个双视图状态,首先我制作一个布尔值来检查用户是否经过身份验证,然后如果是它会将我发送到一个视图,如果我不是它会将我发送到另一个视图。问题是我收到此错误:
传入字典的模型项的类型为“System.Web.Mvc.ViewResult”,但该字典需要 TheNonViolenceProject.Models.ViewModels.PageViewModel`1[TheNonViolenceProject.Models.Pages.EducationPage]' 类型的模型项。
这是我的代码:
public class EducationPageController : PageController<EducationPage> {
private bool isUserLoggedin = true;
public ActionResult Index(EducationPage currentPage) {
PageViewModel<EducationPage> model = PageViewModel.Create(currentPage);
if (isUserLoggedin) {
return View(IndexIsAuthenticated(currentPage));
}
return View(model);
}
public ActionResult IndexIsAuthenticated(EducationPage currentPage {
//isUserLoggedin = User.Identity.IsAuthenticated;
PageViewModel<EducationPage> modelIsAuthenticated = PageViewModel.Create(currentPage);
return View(modelIsAuthenticated);
}
}