HTTP web请求不维护会话 [英] Http web request doesn't maintaining session

查看:158
本文介绍了HTTP web请求不维护会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有计划,我想放弃一些有用的学习材料给我。
本网站维护会话密钥和其他一些关键也。
。如果我试图去嵌套页那么它将把我扔出去,并显示出会话消息。
我无法维持的Web请求类的会话密钥。
,所以请给我一些想法,我怎么能保持在web请求堂课。

I have program where i want to scrap some Useful study material for me. This site maintaining session key and some other key also. If I trying to go nested page then it will throw me out and show session out message. I unable to maintain session key in web request class. so please give me some idea that how can i maintain session in web request class.

推荐答案

您需要维护在整个CookiesCollection您的要求。

You need to maintain the CookiesCollection across your requests.

var request = (HttpWebRequest)HttpWebRequest.Create("http://www.mysite.com/");
var cookies = new CookieContainer();

//Pass the collection along with each request to maintain session
request.CookieContainer = cookies;

当你得到的答复回来,你的容器会自动包含了一组与之相关的cookie。然后,您可以重复使用后续请求该容器。

When you get the response back, your container will automatically contain the set of cookies associated with it. You can then reuse that container with subsequent requests.

这篇关于HTTP web请求不维护会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆