How to use sessions in an ASP.NET MVC 4 application?

后端 未结 5 1499
离开以前
离开以前 2020-11-22 17:02

I am new to ASP.NET MVC. I have used PHP before and it was easy to create a session and select user records based on the current session variables.

I have looked ev

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 17:42

    This is how session state works in ASP.NET and ASP.NET MVC:

    ASP.NET Session State Overview

    Basically, you do this to store a value in the Session object:

    Session["FirstName"] = FirstNameTextBox.Text;
    

    To retrieve the value:

    var firstName = Session["FirstName"];
    

提交回复
热议问题