Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get HttpWebRequest.AllowAutoRedirect to set the cookies when doing a GET/POST on the redrected page?

Is there a way to get the HttpWebRequest object to take the set-cookie header into account when being automatically redirected to another page through the AllowAutoRedirect feature? I need it to maintain the cookie information across redirects; I'd rather not have to implement the redirect myself if the framework can do this for me. This must be a common request since most login pages I've seen usually do this.

like image 430
Mark Avatar asked Apr 21 '09 23:04

Mark


1 Answers

I know to make separate requests (ie. different HttpRequest objects) work with cookies, you need to set the HttpRequest.CookieContainer property on both requests to the same instance of a CookieContainer. You might need that for this case as well.

like image 84
Jonathan Rupp Avatar answered Oct 21 '22 23:10

Jonathan Rupp