Object Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've read through the prevoius posts and coudln't find an answer. I'm getting a "Object reference not set to an instance of an object." and can't figure out why. My pageload sub is check for login = true, then cookie to login, then bounce to login page. So I find if the user isn't logged in and there is no cookie I get this error. I have no drop-downs within the "If Not IsPostBack Then". I have dataasbe calls (datareader) to populate the server objects once login in met. I'm also showing or hiding panels once login is met.
Why is this error occuring (my webconfig fiel is fine, etc.)

Error in: http://www.nasba.com/manage/Default.aspx
Error Message: Object reference not set to an instance of an object.
Stack Trace:
at manageaccount.Page_Load() at System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain()

thanx!
 
Chris,

You need to check if the cookie exists before casting it to a value. For
example, if you are casting the cookie contents to a string you need to wrap
that cast in an if then checking if the cookie is not nothing first.

Dim UserId As Int32 = 0
If Not Request.Cookies.Item("UserId") Is Nothing Then
UserId = CType(Request.Cookies.Item("UserId"), Int32)
End If

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Chris said:
I've read through the prevoius posts and coudln't find an answer. I'm
getting a "Object reference not set to an instance of an object." and can't
figure out why. My pageload sub is check for login = true, then cookie to
login, then bounce to login page. So I find if the user isn't logged in and
there is no cookie I get this error. I have no drop-downs within the "If Not
IsPostBack Then". I have dataasbe calls (datareader) to populate the server
objects once login in met. I'm also showing or hiding panels once login is
met.
Why is this error occuring (my webconfig fiel is fine, etc.)

Error in: http://www.nasba.com/manage/Default.aspx
Error Message: Object reference not set to an instance of an object.
Stack Trace:
at manageaccount.Page_Load() at
System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at
System.Web.UI.Control.LoadRecursive() at
System.Web.UI.Page.ProcessRequestMain()
 
thanx, I thought I was doing that but made a slight change in the order, which I was already doing in another area, and it worked. thanx for hitting me with a brick and waking me up.
 
Back
Top