how can I access Session in preinit function in asp.net?

前端 未结 1 563
迷失自我
迷失自我 2021-01-20 05:21
 void Page_PreInit(Object sender, EventArgs e)
{
    HttpCookie userInfo;
    userInfo = Request.Cookies[\"userInfo\"];
    Session[\"EmpID\"] = userInfo[\"EmpID\"];         


        
相关标签:
1条回答
  • 2021-01-20 05:56

    Allow your class to implement IRequiresSessionState such as:

    public partial class YOUR_ASPX: System.Web.UI.Page , IRequiresSessionState
    {
     // your preinit code
    
    }
    

    this is a flag interface which means not need to implement anything but allows you to access Session.

    0 讨论(0)
提交回复
热议问题