protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["usr"]; IBLL.IStudent stu = BLLFactory.DataAccess.CreateStudent(); int ID = -1; if (null != cookie) { ID = Convert.ToInt32(cookie.Values["ID"]); } if (ID != -1) { try { Model.StudentInfo stuInfo = stu.Get(ID); HyperLink1.Text = stuInfo.Stu_UserName + "的个人中心"; HyperLink1.NavigateUrl = "~/Purchase/AccountInfo.aspx"; HyperLink2.Text = "退出登录"; } catch { Request.Cookies.Remove("usr"); HyperLink1.NavigateUrl = "~/Student/Login.aspx"; HyperLink1.Text = "点击这里登录"; HyperLink2.Text = "没有账号,注册"; } } else { HyperLink1.NavigateUrl = "~/Student/Login.aspx"; HyperLink1.Text = "点击这里登录"; HyperLink2.Text = "没有账号,注册"; } }