Posting to remote site to login and then redirect to site

Discussion in '.NET' started by BradM, Sep 15, 2006.

  1. BradM

    BradM

    Joined:
    Sep 15, 2006
    Messages:
    8
    Location:
    Perth, Western Australia
    I have a site that goes through a login process. Once logged in, you can then go to a specific page.

    I can log into the site using a POST and then nagivate to the page, but the page has references to images etc on the site, so the page is incomplete and unusable.

    I have tried logging on to the site using System.Net.WebRequest.Create(url) and then copying the cookies from System.Net.Cookies to System.Web.HttpCookie and copying the "Set-Cookie" from the header. Followed by a context.response.redirect(<site>). But the site comes back with session expired.

    Have tried dynamic forms, but dont know how to keep control.
    System.Web.HttpContext.Current.Response.Clear();
    System.Web.HttpContext.Current.Response.Write("<html><head>");
    System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", FormName));
    System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", FormName, Method, Url));

    for (int i = 0; i < oNameCollection.Keys.Count; i++)
    {
    System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">",
    oNameCollection.Keys, oNameCollection[oNameCollection.Keys]));
    }

    System.Web.HttpContext.Current.Response.Write("</form>");
    System.Web.HttpContext.Current.Response.Write("</body></html>");
    System.Web.HttpContext.Current.Response.End();
    }
     
    BradM, Sep 15, 2006
    #1
    1. Advertising

  2. BradM

    BradM

    Joined:
    Sep 15, 2006
    Messages:
    8
    Location:
    Perth, Western Australia
    Does anyone have any ideas?
     
    BradM, Oct 11, 2006
    #2
    1. Advertising

  3. BradM

    BradM

    Joined:
    Sep 15, 2006
    Messages:
    8
    Location:
    Perth, Western Australia
    I am still hoping that someone might have some ideas on how to do this.
     
    BradM, May 30, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacob
    Replies:
    0
    Views:
    529
    Jacob
    Jul 8, 2004
  2. Jacob
    Replies:
    0
    Views:
    553
    Jacob
    Jul 8, 2004
  3. Jacob
    Replies:
    0
    Views:
    439
    Jacob
    Jul 8, 2004
  4. Sal
    Replies:
    1
    Views:
    1,036
  5. BodiKlamph@gmail.com

    Help. SessionID is x then y then x then y

    BodiKlamph@gmail.com, Sep 3, 2005, in forum: ASP General
    Replies:
    0
    Views:
    341
    BodiKlamph@gmail.com
    Sep 3, 2005
Loading...

Share This Page