Asp.net mvc 部分视图累积添加问题
我想建立一个模块化的网站。一切都很顺利,但我在累积添加模块时遇到了一个问题。我想动态加载内容,如下所示: 联系人页面:Asp.net mvc 部分视图累积添加问题,asp.net-mvc,razor,partial-views,actionresult,Asp.net Mvc,Razor,Partial Views,Actionresult,我想建立一个模块化的网站。一切都很顺利,但我在累积添加模块时遇到了一个问题。我想动态加载内容,如下所示: 联系人页面: Content.cshtml:Lorem ipsum dolor Contact.cshtml Content.cshtml:地址:第比利斯/格鲁吉亚 但只正确加载第一个内容,如下所示 Content.cshtml:Lorem ipsum dolor Contact.cshtml Content.cshtml:Lorem ipsum dolor 我怎样才能解决这个问题 TBL模
+---------+-------------------------+
| ModulId | PhysicalPath |
+---------+-------------------------+
| 1 | /Content.cshtml |
+---------+-------------------------+
| 2 | /Contact.cshtml |
+---------+-------------------------+
+---------+-------------------------+
| PageId | Page |
+---------+-------------------------+
| 1 | About |
+---------+-------------------------+
| 2 | Contact |
+---------+-------------------------+
tblPage
+---------+-------------------------+
| ModulId | PhysicalPath |
+---------+-------------------------+
| 1 | /Content.cshtml |
+---------+-------------------------+
| 2 | /Contact.cshtml |
+---------+-------------------------+
+---------+-------------------------+
| PageId | Page |
+---------+-------------------------+
| 1 | About |
+---------+-------------------------+
| 2 | Contact |
+---------+-------------------------+
tbl内容
+------------+----------------------------+
| ContentId | Content |
+------------+----------------------------+
| 1 | Lorem ipsun dolor... |
+------------+----------------------------+
| 2 | Adress : Tbilisi/Georgia |
+------------+----------------------------+
tblPageModules
+---------+-------------+-------------+
| PageId | ModuleId | OrderId |
+---------+-------------+-------------+
| 2 | 1 | 1 |
+---------+-------------+-------------+
| 2 | 2 | 2 |
+---------+-------------+-------------+
| 2 | 1 | 3 |
+---------+-------------+-------------+
ModuleRepository.cs
public class ModuleRepository
{
public IEnumerable<Modules> Module { get; set; }
public IEnumerable<PageModules> PageModule { get; set; }
public ContentBlock Content { get; set; }
}
Page.cshtml
@model ModuleRepository
@foreach (var modul in Model.Module)
{
@Html.Partial(@modul.PhysicalPath, Model)
}
@model ModuleRepository
@Html.Raw(@Model.Content.Content)
Content.cshtml
@model ModuleRepository
@foreach (var modul in Model.Module)
{
@Html.Partial(@modul.PhysicalPath, Model)
}
@model ModuleRepository
@Html.Raw(@Model.Content.Content)