Reputation: 34158
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.
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?
Upvotes: 0
Views: 1514