Using CookieContainer with Response.Redirect?



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 =

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.

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


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