public ActionResult ShowBooks() { Book book = new Book() { Id = 1, BookName = "Asp.net", Author = "Dino", ISBN = "ABC24567CD" }; return this.View(book); }
public ActionResult ShowTempData() { Book book = new Book() { Id = 301, BookName = "Python", Author = "Savich", ISBN = "2154kldk" }; TempData["BookData"] = book; return RedirectToAction("ShowTempData2"); }
public ActionResult BookView() { Book book = new Book() { Id= 254, Author = "Gates", BookName = "Msdn", ISBN = "2254uyt" }; Session["BookInfo"] = book; return RedirectToAction("BookViewSession"); }
// use of viewmodel to extract the data public ActionResult ShowBooks2() { Book book = new Book() { Id = 2, BookName = "Intro to MVC", Author = "Galloway", ISBN = "3215EH84" }; Message message = new Message() { MessageText = "This is a test message", MessageFrom = "Padam" }; ShowBookAndMessageViewModel viewModel = new ShowBookAndMessageViewModel() { Book = book, Message = message }; return View(viewModel); }