Im new to MVC. Im fooling around trying to grasp the concept. I have the following code. Its quite straight forward. When the user hits the sort action, it sorts a list and sends the list to the Index Action (there are many other ways how to achieve this, like for example sending a sort bool - As I said, Im just fooling around).
The problem Im encountering is that the model parameter in the Index action is always null. While running (debugging) code is going through the Sort Action and the m=model is not null (has a list of users). I can also follow that it goes directly to index. Can someone please tell me what Im doing wrong? Help will be much appreciated.
public ActionResult Index(List<user> model)
{
if (model == null)
{
model = (from u in UsersList
select u).ToList<user>();
}
return View(model);
}
public ActionResult Sort()
{
var model = from f in UsersList
orderby f.Name ascending
select f;
return RedirectToAction("Index", new {m = model});
}