namespace Models
{
public class Articel
{
public int Id { get; set; }
[Required]
[DisplayName("标题")]
[MaxLength(100)]
public string Title { get; set; }
}
public class Cate
{
public int CateId { get; set; }
[DisplayName("文章类别")]
[Required]
public string CateName { get; set; }
public List<Article> article { get; set; }
}
public class ListModel
{
/// <summary>
/// 文章
/// </summary>
public IList<Article> artcleModel { get; set; }
/// <summary>
/// 文章类别
/// </summary>
public IList<Cate> cateModel { get; set; }
}
}
Action方法编写如下:
public
ActionResult
Index()
{
var
model
=
new
ListModel();
model.artcleModel=
Articel.ToList();
model.cateModel=
Cate.ToList();
return
View(model);
}
View层引用如下:
@model
Models.ListModel
@
foreach
(
var
tt
in
Models.artcleModel)
{
@tt.Title
}
@
foreach
(
var
tt
in
Models.cateModel)
{
@tt.CateName
}
header("location:test.php")跳转成功需要注意的,布布扣,bubuko.com
header("location:test.php")跳转成功需要注意的