Solved

User.Identity.IsAuthenticated problem in global. asax

Posted on 2008-10-15
2
956 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

22 Experts available now in Live!

Get 1:1 Help Now