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学习笔记_JNI hello world

    1.需要准备的工具,eclipse,cdt(c++)插件,cygwin(unix)和 android ndk. 在cygwin的etc目录下将ndk的路径引入到profile文件中,可以在cygwin ...

  2. SQL Server2000安装

    本篇文章介绍了安装SQL Server 2000各版本的软硬件配置要求,企业版安装过程的详细步骤,以及需要注意的事项.其他版本可以参考安装 注意:Windows XP不能装企业版.win2000\wi ...

  3. PHP实现前台同步显示后台任务进度

    一次批量发送几千条短信. 如果直接在后台循环执行虽然可行,但是前台操作用户就只能坐着空等,完全看不到后台执行结果,所以考虑能不能有一种办法可以在php后台执行过程中同时在前台显示后台执行任务进度呢. ...

  4. asp.net中导出excel数据的方法汇总

    1.由dataset生成 代码如下 复制代码 public void CreateExcel(DataSet ds,string typeid,string FileName)    {    Htt ...

  5. jsp中页面间传汉字参数转码

    转码:a.href="./showCont.jsp?tcontent="+encodeURI(encodeURI(tcontent)); 解码:java.net.URLDecode ...

  6. jquery 和 js 对象转换

    核心提示:jquery选择器得到的jquery对象和标准的 javascript中的document.getElementById()取得的dom对象是两种不同的对象类型,一般情况下,如S(’#id’ ...

  7. websphere中由于实际应用没有卸载干净,导致安装不了。以下是完全卸载应用程序的方法

     出现此问题的原因之一:操作界面上没有卸载完成.进行一下操作:1.删除 $WAS_HOME/profiles/AppSrv01/config/cells/...cell/applications下对应 ...

  8. [javascript|基本概念]学习笔记

    1/语法 a.区分大小写 b.标识符(首字符必须是字母/"_"/"$",其他可为字母/"_"/"$"/数字,不能用关键字 ...

  9. 怎样把function中的arguments变成普通数组

    当我们在写一个具有处理可变长度参数的函数时,需要对arguments做一些操作.但是arguments它并不是一个数组,没有数组的各种操作,而且,JS的严格模式中不允许更改它的值. 这时我们需要将它的 ...

  10. JS函数式编程【译】2.3 函数式程序员的工具集