Using CookieContainer with Response.Redirect?

D

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.com/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.
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top