Using CookieContainer with Response.Redirect?

Using CookieContainer with Response.Redirect?

am 18.04.2008 16:41:02 von dave

Hi, I have access to a secure site that I currently go through a login page,
then have to search for company profiles. If I want to link directly to the
profile, I need to have the authentication cookie present first generated
from the login page.

Basically, I want to simulate the login through code to eliminate this step,
grab the cookies in the CookieContainer and then redirect onto the page I
want that requires the cookies in the container. I've figured out how to grab
the cookie using the code below.


CookieContainer cookieContainer = new CookieContainer();

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("https://www.securesite.co m/login.aspx");

req.CookieContainer = cookieContainer;
....
// Return the response.
resp = (HttpWebResponse)req.GetResponse();

In order to link to the following page, I need the authentication cookie in
the CookieContainer..Using a response.Redirect, there's no way to this as far
as I know.

https://www.securesite.com/profile.asp?ticker=msft

Is there another technique? How or can I persist the CookieContainer to the
browser, then do the redirect? Thanks, Dave.