Solved

Redirect in Global.asax page produces infinite loop

Posted on 2008-10-16
3
1,133 Views
Last Modified: 2013-11-07
In the code below, I am trying to use the Global.asax page to check whether the user is logged in and if so if the user is in the role of UnvalidatedEmail, they get redirected to VerifyCode.aspx. However, it keeps looping back to this code after redirect.
Thanks.
Sub Application_AuthorizeRequest(ByVal sender As Object, ByVal e As EventArgs)

If User IsNot Nothing And User.Identity.IsAuthenticated = True Then
 

            If User.IsInRole("UnvalidatedEmail") Then

                Response.Redirect("VerifyCode.aspx")

            End If

End If

end sub

Open in new window

0
Comment
Question by:wilcor14
  • 2
3 Comments
 
LVL 6

Expert Comment

by:mirzas
ID: 22732109
Try this




 

Sub Application_AuthorizeRequest(ByVal sender As Object, ByVal e As EventArgs)

If Request.Path.StartsWith("VerifyCode.aspx") Then Exit Sub

If User IsNot Nothing And User.Identity.IsAuthenticated = True Then

 

            If User.IsInRole("UnvalidatedEmail") Then

                Response.Redirect("VerifyCode.aspx")

            End If

End If

end sub

Open in new window

0
 
LVL 6

Accepted Solution

by:
mirzas earned 500 total points
ID: 22732153
Sorry

If Request.Path.Contains("VerifyCode.aspx") Then Exit Sub

This should work fine.
Sub Application_AuthorizeRequest(ByVal sender As Object, ByVal e As EventArgs)

If Request.Path.Contains("VerifyCode.aspx") Then Exit Sub

If User IsNot Nothing And User.Identity.IsAuthenticated = True Then

 

            If User.IsInRole("UnvalidatedEmail") Then

                Response.Redirect("VerifyCode.aspx")

            End If

End If

end sub

Open in new window

0
 

Author Closing Comment

by:wilcor14
ID: 31506781
Brilliant. Simplicity is Genius. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with Filesystemobject or .NET version 3 36
Run time Error 4 34
SQL Login 17 40
C# Single Form 8 29
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

23 Experts available now in Live!

Get 1:1 Help Now