Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

While redirecting from a IHTTPHandler to some page. If session is null need to redirect .aspx page its working, but if session having value means redirect corresponding page(eg. http://localhost:1234/samples/Demo/index.html) this scenario throws a error.

SampleHandle.cs:
C#
void IHttpHandler.ProcessRequest(System.Web.HttpContext context)
{            
  if (context.Request.RawUrl.ToString().ToLower().Contains("/samples/"))
  {
    if (context.Session["UserID"] == null)
    {
      context.Response.Redirect("login.aspx");
      return;
    }
  }

  context.Response.Redirect(context.Request.Url.OriginalString);
  return;  
}

This is my web.config
XML
< add name="SampleHandle" verb="*" path="samples" type="TestHandler.SampleHandle, TestHandler" />
Posted
Updated 9-Feb-15 23:57pm
v3
Comments
Kornfeld Eliyahu Peter 10-Feb-15 5:57am    
What error? At which line?
Arul Prasad E 10-Feb-15 23:38pm    
My scenario is if current page is "http://localhost:1234/samples/Demo/index.html"
i need to check whether session is null or not. If session is having value means redirect to "http://localhost:1234/samples/Demo/index.html". Concurrently calling this page.
Kornfeld Eliyahu Peter 11-Feb-15 1:07am    
That's not an answer to my question!
What error and where?
Arul Prasad E 11-Feb-15 1:21am    
In Code there is no error.. What happening means in url samples keyword avail the handler triggers i am checking the session value is null or not, If its not null means redirect to same url,So handler calling repeatedly.. Please try the above code.. And you get what's my issue..

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