Próbuję ustalić, czy zmienna Session
istnieje, ale dostaję błąd:nie może wykryć, czy istnieje zmienna Session
System.NullReferenceException: Object reference not set to an instance of an object.
Kod:
// Check if the "company_path" exists in the Session context
if (System.Web.HttpContext.Current.Session["company_path"].ToString() != null)
{
// Session exists, set it
company_path = System.Web.HttpContext.Current.Session["company_path"].ToString();
}
else
{
// Session doesn't exist, set it to the default
company_path = "/reflex/SMD";
}
to dlatego, nazwa Session
"ścieżka_firmy" nie istnieje, ale nie mogę jej wykryć!
Dzięki za odpowiedź, nadal otrzymuję ten sam błąd z tym – Luke
Sprawdź, czy twój bieżący wątek może uzyskać dostęp do System.Web.HttpContext? – Adil
Jak mogę to sprawdzić? Mam 'using System.Web'? Czy to jest poprawne? – Luke