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应用的更多相关文章

  1. C#保存CookieContainer到文件

    摘自:http://licstar.net/archives/6 “C# save CookieContainer to file”,发现了一份优雅的代码.http://stackoverflow.c ...

  2. C# 将cookiecontainer写到本地

    public static void WriteCookiesToDisk(string file, CookieContainer cookieJar) { using(Stream stream ...

  3. c# 中 利用 CookieContainer 对 Cookie 进行序列化和反序列化校验

    private void Form1_Load(object sender, EventArgs e) { var cookieStr = @".CNBlogsCookie=1BE76122 ...

  4. 带CookieContainer进行post

    1.获取CookieContainer ——用户登录 CookieContainer cookie = new CookieContainer(); UserLoginPost("post地 ...

  5. 一个CookieContainer的拓展类

    最近项目中需要频繁用到服务器返回的Cookie,由于项目采用的是HttpClient,并且用CookieContainer自动托管Cookie,在获取Cookie的时候不太方便.所以就写了个拓展类. ...

  6. 如何将webbrowser控件的Cookie倒入CookieContainer供WebRequest使用

    先建一个 "CookieContainer "   把WebBrowser中的Cookie保存在里面                       //在WebBrowser中登录 ...

  7. httpRequest.CookieContainer= cookie 与 httpRequest.Headers.Add("Cookie", cookie)

    这两天做了一个获取cookie并且携带此cookie去请求另外一个url地址,中间携带cookie用了两种方式:1. httpRequest.CookieContainer= cookie (此coo ...

  8. C# HTTP系列4 HttpWebRequest.CookieContainer属性

    系列目录     [已更新最新开发文章,点击查看详细] HttpWebRequest.CookieContainer 获取或设置与此请求关联的 Cookie.默认情况下CookieContainer  ...

  9. C#中CookieContainer获取里面cookie值异常:InvokeMember("m_domainTable") FieldAccessException

    1.可能是主机提供商的 安全问题. Their hosts works in medium trustsecurity, and ASProxy needs a full trust security ...

随机推荐

  1. android APP是否需要缓存?+简单架构

    问题的由来 昨天,当我写完我的第一篇博客之后,我便百无聊赖的玩起了手机!当我打开Google自带的一些app的时候,发现他们直接叫我连接网络,并没有缓存上次从网络获取的数据.这就让我感到很奇怪!于是我 ...

  2. android ListView下拉刷新 上拉加载更多

    背景 最近在公司的项目中要使用到ListView的下拉刷新和上拉加载更多(貌似现在是个项目就有这个功能!哈哈),其实这个东西GitHub上很多,但是我感觉那些框架太大,而且我这个项目只用到了ListV ...

  3. MVC EF ObjectStateManager 中已存在具有同一键的对象。ObjectStateManager 无法跟踪具有相同键的多个对象。

    遇到这个错误  在查询时 加上asNoTracking() 即可

  4. 开放-封闭原则(OCP)

    对于僵化性的臭味,应用OCP原则之后,再进行同样的改动时,只需添加新代码,而不必改动已正常运行的代码. 扩展模块行为的方式通常是修改模块的Code,不允许修改的模块常常被认为是具有固定的行为. Ope ...

  5. 杭电ACM2058--The sum problem

    http://acm.hdu.edu.cn/showproblem.php?pid=2058 以为简单的穷举就完了,结果是一直Time Limit Exceeded.. 这是代码: #include ...

  6. poj 3669 Meteor Shower

                                                                                                      Me ...

  7. [译] 开发者角度,王道之论:Android 与 Windows Phone

    前几天,在codeproject搜索Silverlight资料,偶然看到这篇文章,耐心读了2遍,非常不错:文章通过访谈聊天形式叙述,2位主角目前在<斯法克斯国家工程学院>软件学院上学. 周 ...

  8. javaScript 连续子数列最大和

    <!DOCTYPE html> <html> <head> <title></title> <meta charset=utf-8&g ...

  9. 网络A、B、C类IP地址的区别

    学网络之前得先要明白几个概念:(起初我也不怎么知道后来就慢慢会了) 1字节=8位,1位就是1个数字,所以1字节等于8个数字. 2的8次方,和二进制11111111转换为十进制并不一回事. 0-127是 ...

  10. 字符串反转(charat)

    package com.java1234.chap03.sec08; public class zifufanzhuan { public static void main(String[] args ...