Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
following code is in one of my controller

var model1 = new Book();
model1.id = 1;
model1.BookName = "Life After Life";
model1.Author = "Kate Atkinson";
model1.Classification = "Fiction";
model1.Price = "CND $ 19.95";


Book model2 = new Book();
model2.id = 2;
model2.BookName = "River Of Stars";
model2.Author = "Guy Gavriel Kay";
model2.Classification = "Fiction";
model2.Price = "CDN $32.00";

Book model3 = new Book();
model3.id = 3;
model3.BookName = "Light";
model3.Author = "Michael Grant";
model3.Classification = "JUVENILE";
model3.Price = "CDN $20.99"

List<book> list = new List<book>();


list.Add(model1);
list.Add(model2);
list.Add(model3);
list.Add(model4);
list.Add(model5);

Session["var"] = list;
return View(list);

I want to access the same list in another controller without hardcoding the same list. The session varible is not working ...it returns null. Do How do i achieve this? is my syntax is wrong?.. I'm new to mvc 3 plz give me a specific explanation

Thank you
Posted
Comments
Zoltán Zörgő 29-Apr-13 16:13pm    
This is the problem: you don't use M from MVC. That belongs in the model not in the controller.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900