Question

I'm trying to scrape the URL from an IE browser control after completing Facebook login. The problem arises when I try to detect the redirect after the login. I'm using the Response.Redirect(Url,false) function, but that simply allows me to interact with the page before it loads but not afterward.

How do I detect the redirect after the page has loaded (triggered at end of log in process) when no response object is available in the Page_Unload function? I'm stuck.
The lifecycle doc doesn't mention any state after unload which is exactly when I have to scrape the URL. I've tried using IsPostBack however the code never reaches this point until after I've closed the window. Any help is greatly appreciated.

System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\user_name\LogUnLoad.txt");
System.IO.StreamWriter errorfile = new System.IO.StreamWriter(@"C:\Users\user_name\LogUnLoadError.txt");

try
{
    base.OnUnload(e);

    if (Page.IsPostBack)
    {
        file.Write("\r\n This branch does not get executed. Neither does this");
    }
}
catch( Exception ex)
{
    errorfile.Write("Page_Unload \r\n\t Error Message \r\n\t\t:"+ex.Message +"\r\n\t Stack Trace: \r\n\t"+ex.StackTrace);
    errorfile.Close();
    file.Close();
}

source for page lifcycle: http://msdn.microsoft.com/en-us/library/ms178472(v=vs.85).aspx

Update: I'm the Global.asax file suggested here .
I thought asking for the previous URL before close would be the solution but no dice.

Was it helpful?

Solution

Just in case someone likes to skip over the comments I'll put this here.

If you check the HttpRequest.UrlReferrer you can get the URL of the previous page. This can be used to check for redirects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top