Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC
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 list = new List();
 

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 29-Apr-13 11:05am
rajh1270
Comments
Zoltán Zörgő at 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)

  Print Answers RSS
0 OriginalGriff 275
1 Maciej Los 230
2 Sergey Alexandrovich Kryukov 185
3 Afzaal Ahmad Zeeshan 152
4 ProgramFOX 130
0 OriginalGriff 6,524
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,218
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100