-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;
    }
}

}

当我执行 Response.Write 时,我收到“NullReferenceException 未被用户代码处理”,为什么会发生这种情况?

4

1 回答 1

3

您正在尝试使用另一个键从会话对象中读取,而不是在上面的行中写入(“IDutil”不等于“IDultil”)

Session ["IDutil"] = UserID;
Response.Write(Session["IDultil"].ToString()); // Session["IDultil"] will be null
于 2013-03-08T19:47:21.597 回答