[英]ASP.NET MVC 4 Model is null after post
Hello this is my product controller i have one one table and one form in view. 您好,这是我的产品控制器,我有一张一张桌子和一张表格。 When I submit model.
当我提交模型时。 Product everything ok but when I return view from HttpPost Index model is always null.
产品一切正常,但是当我从HttpPost索引模型返回视图时始终为null。
If I reload page model is filled. 如果我重新加载页面模型已填充。
public ActionResult Index()
{
var model = new ProductViewModel();
var suppliers = new List<Supplier>();
var categories = new List<GoodsCategory>();
using (var session = _sessionFactory.OpenSession())
{
model.Products = session.Query<Product>().ToList();
suppliers = (from d in session.Query<Supplier>()
select new Supplier
{
Id = d.Id,
Name = d.Name
}).ToList();
categories = session.Query<GoodsCategory>().ToList();
model.Suppliers = suppliers;
model.Categories = session.Query<GoodsCategory>().ToList();
}
return View(model);
}
[HttpPost]
public ActionResult Index(ProductViewModel model)
{
return View()
}
Does anybody knows whats wrong in my code? 有人知道我的代码有什么问题吗?
type return View(model);
输入
return View(model);
in post action 事后行动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.