ここで二重のビュー状態を作成しようとしています。まず、ユーザーが認証されているかどうかを確認するブール値を作成し、認証されている場合はビューに送信し、認証されていない場合は別のビューに送信します。問題は、次のエラーが発生することです。
ディクショナリに渡されたモデル アイテムのタイプは「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);
}
}