I have a custom class User
public class User
{
public string UserId { get; set; }
public string LesseeCode { get; set; }
public string ClientId { get; set; }
public string VehicleId { get; set; }
public string Status { get; set; }
public string UnitDesc { get; set; }
public string ItemId { get; set; }
public string Category { get; set; }
public string Type { get; set; }
public double Amount { get; set; }
}
And when I try to define a new user here
public static User currentUser = (HttpContext.Current.Session["User"] == null) ? (User)HttpContext.Current.Session["User"] : new User();
I get a System.NullReferenceException
error, I read that this is usually caused by a variable that is not nullable either not bing defined or being defined null , however based on how I defined currentUser there should be no way for it to be null?