-4
protected void Btnlogin_Click(object sender, EventArgs e)
{
    BLL.Bll Bll = new BLL.Bll();
    String Result = Bll.Login(TBNomelog.Text, TBPasslog.Text);
    String UserID = Bll.UserID(TBNomelog.Text);
    Session ["IDutil"] = UserID;
    Response.Write(Session["IDultil"].ToString());

    if (Result.Equals("True"))
    {
        MultiView1.ActiveViewIndex = 2;
    }
    else
    {
        MultiView1.ActiveViewIndex = 1;
    }
}

}

I'm getting "NullReferenceException was unhadled by user code" when i execute Response.Write Any sugestions why this may be happening?

Oded
  • 489,969
  • 99
  • 883
  • 1,009
I4Got
  • 1
  • 2
  • 1
    Debug through. What is the value of `UserID` when that line is called? – Oded Mar 08 '13 at 19:46
  • 2
    Welcome to Stack Overflow! Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. – John Saunders Mar 08 '13 at 20:02

1 Answers1

3

You are trying to read from session object with another key than you are writing in row above ("IDutil" is not equal to "IDultil)

Session ["IDutil"] = UserID;
Response.Write(Session["IDultil"].ToString()); // Session["IDultil"] will be null
gregjer
  • 2,823
  • 2
  • 19
  • 18