2013-03-07 53 views
0

你好,这是我的产品控制器我有一个表和一种形式的视图。当我提交模型。产品一切正常,但是当我从HttpPost返回视图索引模型始终为空。ASP.NET MVC 4模型后为空

如果我重新加载页模型填充。

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() 
    } 

有没有人知道我的代码有什么问题?

回答

4

type return View(model); in post action