Solved

Redirect in Global.asax page produces infinite loop

Posted on 2008-10-16
3
1,127 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

15 Experts available now in Live!

Get 1:1 Help Now