2013-03-07 5 views
0

안녕하세요. 내 제품 컨트롤러입니다. 하나의 테이블과 하나의 양식이 있습니다. 내가 모델을 제출할 때. 제품 모두 괜찮지 만 HttpPost에서 뷰를 반환 할 때 인덱스 모델은 항상 null입니다.게시 후 ASP.NET MVC 4 모델이 null입니다.

페이지를 새로 고침하면 모델이 채워집니다.

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

유형 return View(model); 조치 후