Posting to remote site to login and then redirect to site

Joined
Sep 15, 2006
Messages
8
Reaction score
0
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();
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top