0

I have been having trouble with inProc session variables returning null. The most current is trying to set a Session Variable in the PageLoad of Default. Here is my code.

   string NameNew = Page.User.Identity.Name;
    if (NameNew.Contains('\\'))
    {
        NameNew = NameNew.Split('\\').Last();
    }
    if (Session != null)
    {
        Session["UsersName"] = NameNew;
    }

When debugging it returns System.NullReferenceException: 'Object reference not set to an instance of an object.'

I have tried updating vs, checking IIS express for session issues, moved other session objects to base class. I am at a loss.

0 Answers0