Wierd cookie error

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
 
B

Bobby Edward

I believe the problem is when a cookie does NOT exist. The line isn't
checking it correctly???? Ideas? Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top