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 ...
随机推荐
- Part 97 Performance of a multithreaded program
class Program { static void Main(string[] args) { Stopwatch s = new Stopwatch(); s.Start(); EvenNumb ...
- GitHub之创建
O(∩_∩)O~ 爱“搞事”的我又创了一个Github账号,和当初加入博客园的初衷一样,为了广泛交流和学习而已.很久之前我就发现了有很多人都在使用GitHub,然而当时看不懂英文(绝大部分都是英文), ...
- Swiper之初识
何为Swiper?Swiper是一款免费以及轻量级的移动设备触控滑块的框架,使用硬件加速过渡(如果该设备支持的话).主要使用与移动端的网站.网页应用程序(web apps),以及原生的应用程序(nat ...
- 批处理脚本修改hosts文件指定域名解析IP
现在很多网站都是前后台分开部署的,这样做是相对安全的.就算黑客拿到了前台shell也找不到后台的管理地址,增加安全性. 大家应该知道hosts文件的功能吧,用户在访问网站的时候 需要把域名解析成IP地 ...
- Java类加载的时机_4种主动引用会触犯类加载+剩下的被动引用不会触发类的加载
转载自:http://chenzhou123520.iteye.com/blog/1597597 Java虚拟机规范没有强制性约束在什么时候开始类加载过程,但是对于初始化阶段,虚拟机规范则严格规定了有 ...
- C#如何关闭一个窗口的同时打开另一个窗口
在.net的WinForm程序中,如果是直接起动的Form作为主窗口,那么这个主窗口是不能关闭的,因为它维护了一个Windows消息循环,它一旦关闭了就等于声明整个应用程序结束,所以新打开的窗口也就被 ...
- Floyd最短路径算法
看完这篇文章写的小程序,Floyd最短路径算法,求从一个点到另一个点的最短距离,中间可以经过其他任意个点.三个for循环,从i到j依次经过k的最短距离,最外层for循环是经过点K,内部两个循环是从i( ...
- UI2_UIGesture
// // ViewController.h // UI2_UIGesture // // Created by zhangxueming on 15/7/9. // Copyright (c) 20 ...
- Android四大组件之一:Activity
介绍:活动是最基本的Android组件之一,在应用程序中,一个活动通常就是一个用户界面,每一个活动都被实现为一个独立的类,并且从活动几类中继承, 活动类将会显示由View控件组成的用户接口,并对时间E ...
- 济南学习 Day 4 T2 am
LYK 与实验室(lab)Time Limit:5000ms Memory Limit:64MB题目描述LYK 在一幢大楼里,这幢大楼共有 n 层,LYK 初始时在第 a 层上.这幢大楼有一个秘密实验 ...