2011-04-26 29 views
0

有可能有動態嵌套_layout頁面?如何使用剃鬚刀動態嵌套_Layout?

這裏就是我的了:

_ShopDetailsLayout.cshtml(動態嵌套_layout):

@model MVC.Web.Areas.Shop.Models.ShopDetailViewModel 

@{ 
    Layout = "~/Views/Shared/_Layout.cshtml"; 
} 

Credits.cshtml:

@model MVC.Web.Areas.Shop.Models.CreditsViewModel 

@{ 
    ViewBag.Title = "Credits"; 
    Layout = "~/Areas/Game/Views/Shared/_ShopDetailsLayout.cshtml"; 
} 

我遇到的問題是,其他頁面,就像Credits.cshtml使用的嵌套佈局沒有相同的@model,所以我得到這個錯誤:

The model item passed into the dictionary is of type 'MVC.Web.Areas.Shop.Models.CreditsViewModel', but this dictionary requires a model item of type 'MVC.Web.Areas.Shop.Models.ShopDetailViewModel'.

我希望有人能幫助

回答

0

你需要改變你的佈局,以與實際型號兼容。
您可能想要使用通用的基本類型,或者使用默認的dynamic模型。