Httpwebrequest通过拒绝/禁用cookie发出请求

时间:2014-04-27 13:14:39

标签: c# asp.net http

你好我做了一个简单的httpwebrequest,但我得到的回复是播下我同样的页面,就好像我在(F12)中手动将cookie设置为拒绝。任何人都知道如何解决它 看来我的httpwebrequest似乎有cookies =拒绝设置

我只想发送HttpWebRequest然后从HttpWebResponse读取html页面,但是我从HttpWebResponse获取的html页面就像是我在(F12)browser.i中手动将cookie设置为拒绝。我这样做是为了检查并获取同页

这是我的代码

    using System;
    using System.IO;
    using System.Diagnostics;
    using System.Text;
    using System.Collections.Generic;
    using HtmlAgilityPack;
    using System.Net;
    using System.Web;
    using System.Text.RegularExpressions;

    namespace BbvaBank
    {
        static class bBank
        {
            static CookieContainer _cookies = new CookieContainer();



    static string loginPostUrl = "https://www.bbvanetcash.com/local_kyop/KYOPSolicitarCredenciales.html";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(loginPostUrl);
    request.CookieContainer = new CookieContainer();
    request.AllowAutoRedirect = true;
    //Get the response from the server and save the cookies from the first request..

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
request.CookieContainer = _cookies;
Stream streamResponseLogin = response.GetResponseStream();
StreamReader streamReadLogin = new StreamReader(streamResponseLogin);
LoginInfo = streamReadLogin.ReadToEnd();//here i see the page

    }

    }

0 个答案:

没有答案