在我所做的登录页面上,这是提交按钮后面的代码的一部分。Cookies未被添加
Dim aCookie As New HttpCookie("userInfo")
aCookie.Values("user") = Me.usr.Text
aCookie.Values("last") = Now.ToString()
If Me.remember.Checked() Then
aCookie.Expires = DateTime.Now.AddDays(3650)
Else
aCookie.Expires = DateTime.Now.AddHours(1)
End If
Response.Cookies.Add(aCookie)
'Response.Redirect("~/Default.aspx")
testBox.Text = Response.Cookies("userInfo")("user").ToString()
出于某种原因,当它到达最后一行时,它抛出一个错误:
说明:在当前Web请求的执行过程中发生未处理的异常。请查看堆栈跟踪以获取有关该错误的更多信息以及源代码的位置。
异常详细信息:System.NullReferenceException:未将对象引用设置为对象的实例。
这是由同时拿刀砍和编辑代码张贴在这里它的部分错误。这个问题在我的项目中不是什么问题。编辑并修复。 –