Wierd cookie error

  • Thread starter Thread starter Bobby Edward
  • Start date Start date
B

Bobby Edward

Here's my code...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then
' THIS IS LINE 11
If Request.Cookies("UserSettings")("IsAdmin") = "True" Then
Me.panAdmin.Visible = True
Else
Me.panAdmin.Visible = False
End If
End If
End Sub

Works perfectly locally. But, when I upload it to the production server I
get this error.... Any ideas????
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]
BeachFuneralMain.Page_Load(Object sender, EventArgs e) in
F:\work-related\websites\BeachFuneral\BeachFuneralMain.master.vb:11
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
 
I believe the problem is when a cookie does NOT exist. The line isn't
checking it correctly???? Ideas? Thanks!
 
Back
Top