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 ...
随机推荐
- 2012的数据库 select @@version 都是说版本为2008 R2
如图 我使用的是sqlserver2012登录的,select @@version 查询出来的却是2008 ,而且附加不了2012的数据库. 在网上搜到解决方法:1确认是否安装了2012(废话没安装是 ...
- AJAX之JSON
AJAX=Asynchronous JavaScript and XML(异步的JavaScript 和XML). AJAX不是新的编程语言,而是一种是用现代标准的新方法,用于创建快速动态网页的技术. ...
- SQL IDENTITY(int,1,1) 用法
select IDENTITY(int,1,1) as SortID from tb_order 仅当 SELECT 语句中有 INTO 子句时,才能使用 IDENTITY 函数. select ID ...
- OS中常用的调度算法总结 (转)
http://blog.chinaunix.net/uid-25132162-id-361291.html 一.常见的批处理作业调度算法 1.先来先服务调度算法(FCFS):就是按照各个作业进入系统的 ...
- 清除windows的EFS加密
所使用软件为aefsdr_setup_en,搜索名为advanced.efs.data.recovery 1. 创建需要加密的文件 2. 进行加密 ...
- IIS7下swfupload上传大文件出现404错误
要求上传附件大小限制在2G,原本以为可以轻松搞定.在编译模式下可以上传大文件,可是在IIS7下(自己架的服务器),一上传大的文件就会出现 Http 404错误,偶尔有的文件还有IO. error错误. ...
- Angularjs入门学习一 简介
本系列文章是从头开始学习angularjs,下文中用ng表示angularjs,要知道从以为根深蒂固的jquery开发者转变开发思想,确实需要一段时间,下面介绍以下 angularjs,我也是参考网上 ...
- Android实现Http协议案例
在Android开发中,使用Http协议实现网络之间的通信是随处可见的,使用http方式主要采用2中请求方式即get和post两种方式. 一.使用get方式: HttpGet httpGet = ne ...
- SPA解释:单页应用程序
单页Web应用(single page web application,SPA),就是只有一张Web页面的应用,是加载单个HTML 页面并在用户与应用程序交互时动态更新该页面的Web应用程序. 单页W ...
- MySQL用命令行导出数据库
MySQL命令行导出数据库:首先进入cmd然后:1. cd C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin2. mysqldump -uroot - ...