Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i create handler code
C#
public bool IsReusable
       {
           get { return false; }
       }

       public void ProcessRequest(HttpContext context)
       {
           if (string.IsNullOrEmpty(context.Session["mySession"] as string))
           {
               string url = HttpContext.Current.Request.Url.AbsoluteUri;
               url = url.ToUpper();
               if (url.Contains("MYFOLDER"))
               {
                   context.Response.Redirect("Login.aspx");
               }
              
               else
               {
                   string url1 = HttpContext.Current.Request.Url.AbsoluteUri; 
                  context.Response.Redirect(url1);
               }
           }

            
       }

web config
XML
<system.webServer>
    <handlers>
      <add name="Admin" verb="*" path="*.aspx" type="mySite.Protected, mySite"/>
    </handlers>
  
  </system.webServer>


but method
C#
ProcessRequest(HttpContext context)
do loop
pleas help me

What I have tried:

i tried
context.Response.Redirect(url1,true);

but no answer
Posted
Updated 15-Apr-16 4:40am
v2
Comments
F-ES Sitecore 15-Apr-16 7:15am    
If the url doesn't contain myFolder it redirects to itself, so the handler executes again and so on and so on. You'll need to explain what it is you're trying to achieve.
Richard Deeming 15-Apr-16 9:04am    
Even if the URL does contain myFolder, the .ToUpper() call means the code always falls into the else branch, and redirects to itself.
F-ES Sitecore 15-Apr-16 9:07am    
Good spot!
mah1353 15-Apr-16 10:39am    
yes but there is same problem
if (url.Contains("MYFOLDER"))
{
context.Response.Redirect("Login.aspx");
}
mah1353 15-Apr-16 10:44am    
context.Response.Redirect is always loop to start method ProcessRequest(HttpContext context) and do not exit from method

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900