cookieContainer应用
PublicSharedFunctionGetCookiesSetByPage(ByVal strUrl AsString,ByVal cookieToProvide AsString)AsIEnumerable(OfString)
Dim req AsSystem.Net.HttpWebRequest
Dim res AsSystem.Net.HttpWebResponse
Dim sr AsSystem.IO.StreamReader
'--notice that the instance is created using webrequest
'--thisis what microsoft recomends
req =System.Net.WebRequest.Create(strUrl)
'set the standard header information
req.Accept="*/*"
req.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)"
req.ContentType="application/x-www-form-urlencoded"
req.AllowAutoRedirect=False
req.Headers.Add(HttpRequestHeader.Cookie, cookieToProvide)
res = req.GetResponse()
'read in the page
sr =NewSystem.IO.StreamReader(res.GetResponseStream())
Dim strResponse AsString= sr.ReadToEnd
'Get the cooking from teh response
Dim strCookie AsString= res.Headers(System.Net.HttpResponseHeader.SetCookie)
Dim strRedirectLocation AsString= res.Headers(System.Net.HttpResponseHeader.Location)
Dim result AsNewList(OfString)
IfNot strCookie =NothingThen
result.Add(strCookie)
EndIf
result.Add(strRedirectLocation)
Return result
EndFunction
cookieContainer应用的更多相关文章
- C#保存CookieContainer到文件
摘自:http://licstar.net/archives/6 “C# save CookieContainer to file”,发现了一份优雅的代码.http://stackoverflow.c ...
- C# 将cookiecontainer写到本地
public static void WriteCookiesToDisk(string file, CookieContainer cookieJar) { using(Stream stream ...
- c# 中 利用 CookieContainer 对 Cookie 进行序列化和反序列化校验
private void Form1_Load(object sender, EventArgs e) { var cookieStr = @".CNBlogsCookie=1BE76122 ...
- 带CookieContainer进行post
1.获取CookieContainer ——用户登录 CookieContainer cookie = new CookieContainer(); UserLoginPost("post地 ...
- 一个CookieContainer的拓展类
最近项目中需要频繁用到服务器返回的Cookie,由于项目采用的是HttpClient,并且用CookieContainer自动托管Cookie,在获取Cookie的时候不太方便.所以就写了个拓展类. ...
- 如何将webbrowser控件的Cookie倒入CookieContainer供WebRequest使用
先建一个 "CookieContainer " 把WebBrowser中的Cookie保存在里面 //在WebBrowser中登录 ...
- httpRequest.CookieContainer= cookie 与 httpRequest.Headers.Add("Cookie", cookie)
这两天做了一个获取cookie并且携带此cookie去请求另外一个url地址,中间携带cookie用了两种方式:1. httpRequest.CookieContainer= cookie (此coo ...
- C# HTTP系列4 HttpWebRequest.CookieContainer属性
系列目录 [已更新最新开发文章,点击查看详细] HttpWebRequest.CookieContainer 获取或设置与此请求关联的 Cookie.默认情况下CookieContainer ...
- C#中CookieContainer获取里面cookie值异常:InvokeMember("m_domainTable") FieldAccessException
1.可能是主机提供商的 安全问题. Their hosts works in medium trustsecurity, and ASProxy needs a full trust security ...
随机推荐
- 百度编辑器ueditor代码高亮效果前台不显示的解决方法
原因是你没有在你的内容页加载相应的css文件,这要如何解决呢? 经测试,只要插入以下两个文件即可解决问题: <link href="你的ueditor路径/ueditor/third- ...
- 虚拟机中Linux安装Tools
1. 插入光盘后将文件拷贝到常用放置软件的目录 2. 解压文件 3. 然后进入解压后的文件夹里找到安装文件进行安装(注意使用root权限安装) 4. 安装时也是一个交互的过程 5. 完成安装
- C# HttpWebRequest类
HttpWebRequest类与HttpRequest类的区别. HttpRequest类的对象用于服务器端,获取客户端传来的请求的信息,包括HTTP报文传送过来的所有信息.而HttpWebReque ...
- 【转】 memwatch使用说明书
memwatch使用说明书 1.memwatch是什么? memwatch是C语言的内存检测器.除了检测内存的功能外,它同样可以做其它的一些事情,而我们主要还是在于讲述它的基本功能.如果你真的想 ...
- 6步图文教你优化myeclipse2014
MyEclipse 2014优化速度方案仍然主要有这么几个方面:去除无需加载的模块.取消冗余的配置.去除不必要的检查.关闭更新. 第一步: 去除不需要加载的模块 一个系统20%的功能往往能够满足80% ...
- hive安装配置错误
1.Access denied for user 'hive'@'localhost' (using password: YES) 解决办法: 执行 hive --service metastore ...
- 实例:使用纹理对象创建Sprite对象
精灵类是Sprite,它的类图如下图所示: Sprite类直接继承了Node类,具有Node基本特征.此外,我们还可以看到Sprite类的派生类有:PhysicsSprite和Skin.Physics ...
- 【学习笔记】【C语言】第一个C程序
1.新建C语言程序 *打开Xcode *新建文件 *选择C语言程序 *输入程序名称 *选择存放路径 *创建完成后 2.也可以用终端来创建 通过指令来创建.c文件 3.编写代码 4. ...
- 精美jQuery插件及源码 前端开发福利
jQuery是一个非常不错的javascript框架,很多前端开发者喜欢的原因不仅是因为jQuery使用起来方便,更重要的是因为它的插件很多,我们可以将这些插件应用到自己的项目中去.下面这些精美的jQ ...
- HDU 5093 Battle ships(二分图最大匹配)
题意:一个m行n列的图由#.*.o三种符号组成,分别代表冰山.海域.浮冰,问最多可放的炮舰数(要求满足以下条件) 1.炮舰只可放在海域处 2.两个炮舰不能放在同一行或同一列(除非中间隔着一个或多个冰山 ...