Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

User.Identity.IsAuthenticated problem in global. asax

Posted on 2008-10-15
2
Medium Priority
?
999 Views
Last Modified: 2013-11-07
In the code snippet below, I am trying to see if the user is logged in and has verified their email using the role manager of .net. As the application loads, the User.Identity.IsAuthenticated produces a
Object reference not set to an instance of an object error

Can anyone help me find a work around. Thanks.
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
       If User.Identity.IsAuthenticated <> Nothing Then
            If User.IsInRole("UnvalidatedEmail") Then
                Response.Redirect("VerifyCode")
            End If
        End If
end sub

Open in new window

0
Comment
Question by:wilcor14
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:JBart_17
ID: 22724569
0
 
LVL 11

Accepted Solution

by:
William earned 2000 total points
ID: 22724601
try
Public Sub Application_AuthenticateRequest(sender As Object, e As EventArgs) 
    If User IsNot Nothing Then 
        If User.Identity IsNot Nothing Then 
            If User.Identity.IsAuthenticated IsNot Nothing Then 
                If User.IsInRole("UnvalidatedEmail") Then 
                    Response.Redirect("VerifyCode") 
                End If 
            End If 
        End If 
    End If 
End Sub 

Open in new window

0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question