5
Reply

How to maintain session in Asp.net MVC?

Pradeep Yadav

Pradeep Yadav

7y
5.7k
0
Reply

    We dont have session in mvc but we can store data with the help of tempdata, viewdata , viewbag

    To pass a Seesion We use- System.Web.HttpContext.Current.Session[“UserArticleId”] = articleId;

    To hold the value of a session we use-
    var articleId = System.Web.HttpContext.Current.Session[“UserArticleId”];
    For clear a session - System.Web.HttpContext.Current.Session.Clear();

    Viewbag,tempdata,viewdata

    HttpContext.Current.Session

    You can use tempdata, viewdata and viewbag.