Solved

User.Identity.IsAuthenticated problem in global. asax

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Very Large data in MYSQL 7 73
bound data table problem 2 32
how to hit button in form and close application from main() 4 20
how to just get time from a date 6 32
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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