In this article I will explain with an example, how to store Model in Session inside Controller and display in View in ASP.Net MVC Razor.
This article will illustrate how to save Model object in Session variable inside Controller and then access it using Razor syntax inside View in ASP.Net MVC Razor.
The Model class has the following properties.
public class PersonModel
    public string Name { get; set; }
    public string Degree { get; set; }
The Controller consists of the Index Action method. Inside this Action method, the Model class object is stored in Session object and simply the View is returned.
public class HomeController : Controller
    // GET: Home
    public ActionResult Index()
        PersonModel model = new PersonModel()
            Name = "Mudassar Khan",
            Degree = "BE"
        Session["Data"] = model;
        return View();
Inside the View, the Session object is again type casted back to the Model type and the values are displayed using Razor syntax.
@using Session_Model_MVC.Models
    Layout = null;
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width"/>
        Name: @((Session["Data"] as PersonModel).Name)
        Degree: @((Session["Data"] as PersonModel).Degree)
Store Model in Session and display in View in ASP.Net MVC