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

x
?
Solved

Redirect in Global.asax page produces infinite loop

Posted on 2008-10-16
3
Medium Priority
?
1,174 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
[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
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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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