Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# access session in class

public class MySession
{
    // private constructor
    private MySession()
    {
      Property1 = "default value";
    }

    // Gets the current session.
    public static MySession Current
    {
      get
      {
        MySession session =
          (MySession)HttpContext.Current.Session["__MySession__"];
        if (session == null)
        {
          session = new MySession();
          HttpContext.Current.Session["__MySession__"] = session;
        }
        return session;
      }
    }

    // **** add your session properties here, e.g like this:
    public string Property1 { get; set; }
    public DateTime MyDate { get; set; }
    public int LoginId { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: parse datetime c# 
Csharp :: c# add string to array 
Csharp :: c# datagridview hide row selector 
Csharp :: unity button onclick 
Csharp :: c# change label from thread 
Csharp :: swap two numbers c# 
Csharp :: c# add multiple items to list 
Csharp :: c# enum syntax 
Csharp :: c# how to fill a datatable 
Csharp :: ajax asp.net core 
Csharp :: project mongodb c# 
Csharp :: route attribute controller with parameter asp.net core 
Csharp :: unity color by rgb 
Csharp :: calculate distance using latitude and longitude c# 
Csharp :: sequelize count all 
Csharp :: get current time c# 
Csharp :: write last element of dictionary c# 
Csharp :: wpf color picker 
Csharp :: get key value from object c# 
Csharp :: declare dictionary c# 
Csharp :: how to deactivate an object unity 
Csharp :: mfind how many digits a number has c# 
Csharp :: unity get center of object 
Csharp :: asp.net 5 iis HTTP Error 500.19 - Internal Server Error 
Csharp :: c# new list of objects 
Csharp :: how to validate if date is a weekday or weekend c# 
Csharp :: c# switch case greater than 
Csharp :: Show private fields in Unity Inspector 
Csharp :: maclaurin series 
Csharp :: what is void onmousedown() 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =