Undefined object reference for an instance of an object. C# Httpcontext.Current.Session

Asked

Viewed 14 times

-1

Guys, I have the new system here of the company trying to run it on localhost, but when I log in it returns this message:

Referência de objeto não definida para uma instância de um objeto.

Here’s the part where he returns that message:

public string verificaLogin() {
    try {
        string actLogin = HttpContext.Current.Session["actLogin"].ToString();
        string actl = actLogin.Split('|')[0];
        if (actl == "ujl") {
            return "false";
        } else {
            return "true";
        }
    } catch (Exception ex) {
        return ex.Message;
    }
}

More specifically this part here:

string actLogin = HttpContext.Current.Session["actLogin"].ToString();

I appreciate any attempt at help!

  • and has already debugged to see what is null? probably Session

  • The session is returning null, but what is strange is that he is searching the data in the database. When I enter the wrong user or password, it returns that the user does not exist or the password is wrong.

  • so there’s your problem :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.