locked
URLRefferer RRS feed

  • Question

  • User431591932 posted

    Hi, 

    I stuck with the finding whether my page (originalpage.aspx) has just URL Refferer . If it doen't have URL Refferer, it should return to somepage.aspx. If it has URL refferer it should return to the originalpage.aspx

    Here is my code

    public void ProcessRequest(System.Web.HttpContext context)

    {

    HttpRequest objRequest = context.Request;

    String strrawURL = context.Request.RawUrl;

    String redir = System .Configuration .ConfigurationManager .AppSettings [context.Request.Url.Host];

    if (redir != null)

    {

    if (objRequest.UrlReferrer != null) { context.Response.Redirect(redir, true);}else { context.Response.Redirect("/OriginalPage.aspx");}

    }

    }

    public bool IsReusable

    {

    get {return true;}

    }

    I have added the below to my web.config

    <add verb="*" path="*/OriginalPage.aspx" type="MyHandler.NewHandler,MyHttpHandler"/>

     

    Now myproblem is the originalpage.aspx is getting looped, Can anyone please tell me how to come out the loop after checking once.

    Suren 

     

     

     

    Wednesday, July 18, 2007 10:01 AM

All replies

  • User-168033412 posted

    Hi,

    Don't redirect to OriginalPage.aspx, or in simple terms don't use your else part. 

    Tuesday, August 28, 2007 7:20 AM
  • User-11442668 posted

     If the browser doesn't send the header, it's very unlikely that it will send the header when it's redirected.. (Thus, he requests the page again (still without the header), and gets redirected (go back to beginning of sentence))

    Saturday, September 1, 2007 2:56 PM