开发者

Keeping session id when getting source code from web page

开发者 https://www.devze.com 2023-03-05 10:44 出处:网络
I\'m making a C# windows form application that needs to parse data from an external site that requires me to log in.

I'm making a C# windows form application that needs to parse data from an external site that requires me to log in.

First I send the POST data on the login page using a WebRequest. This works correctly as I can see the page source of a page that requires me to log in.

When I try to view the page source code of the data-page however, I'm logged out again as the session gets lost.

Is there any way of storing the PHPSESSID and re-using it in another request?

EDIT:

WebRequest _theRequest;
...
_theRequest = (HttpWebRequest)WebRequest.Create(url);
_theRequest.CookieContainer = new CookieContainer();

The property CookieContainer is not showing up in the i开发者_如何学编程ntellisense list, anything I'm doing wrong here?


You could assign a CookieContainer and reuse the request object for subsequent requests.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号