Solved

User.Identity.IsAuthenticated problem in global. asax

Posted on 2008-10-15
2
950 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
2 Comments
 
LVL 5

Expert Comment

by:JBart_17
ID: 22724569
0
 
LVL 11

Accepted Solution

by:
William earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now