Click here to Skip to main content
11,922,641 members (57,780 online)
Rate this:
Please Sign up or sign in to vote.
See more: MVC
following code is in one of my controller

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

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

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

List list = new List();


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 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
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151125.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2015
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