AllowAutoRedirect property is true, the Referer property is set automatically when the request is redirected to another site.">如果 AllowAutoRedirect 属性为 true,则 Referer 属性在请求被重定向到另一个站点时自动设置。

Referer HTTP header, set the Referer property to null.">若要清除 RefererHTTP 标头,请将 Referer 属性设置为 null。
如果设置了  Referer 则 指定到某个站点. 被这东西小坑了一下 涨姿势。

          private bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true; //总是接受安全证书
} private void test()
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
CookieCollection _cookies = null; //后续使用
var addRess = "https://xxxxxxxxxx";
var data = "account=xxxxxxx&password=xxxxx"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(addRess);
request.CookieContainer = new CookieContainer();
request.Timeout = * ;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.AllowAutoRedirect = true;
request.Referer = addRess; byte[] bs = Encoding.UTF8.GetBytes(data);
HttpWebResponse response = null;
StreamReader myStreamReader = null;
Stream myRequestStream = null;
request.ContentLength = bs.Length;
string retString = string.Empty;
try
{
using (myRequestStream = request.GetRequestStream())
{
myRequestStream.Write(bs, , bs.Length);
myRequestStream.Close();
}
response = (HttpWebResponse)request.GetResponse();
_cookies = response.Cookies;
using (Stream myResponseStream = response.GetResponseStream())
{
using (myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("BIG5")))
{
retString = myStreamReader.ReadToEnd();
}
}
}
catch (Exception)
{ throw;
}
finally
{
if (myRequestStream != null)
{
myRequestStream.Close();
}
if (response != null)
{
response.Close();
}
if (myStreamReader != null)
{
myStreamReader.Close();
}
}
}

.net 模拟登陆 post https 请求跳转页面的更多相关文章

  1. 杂记-格式化Date默认格式,日期加一天,jstl判断字符类型,ajax模拟from表单后台跳转页面,jstl访问数据库并在页面显示

    1.格式化Date默认格式 String str="Sun Oct 08 22:36:45 CST 2017"; SimpleDateFormat sdf = new Simple ...

  2. 模拟http或https请求,实现ssl下的bugzilla登录、新增BUG,保持会话以及处理token

    1.增加相应httpclient 需要的jar包到工程,如果是maven工程请在pom.xml增加以下配置即可: <dependency> <groupId>org.apach ...

  3. 解决Nginx+Tomcat下客户端https请求跳转成http的问题

    Nginx上开启https,  后端使用Tomcat,  两者间走http协议, 但发现如果tomcat应用存在跳转时, 则客户端浏览器会出现400 Bad Request的错误, 通过抓包发现原因是 ...

  4. http模拟登陆及发请求

    首先声明下,如果服务端写入的cookie属性是HttpOnly的,程序是不能自动获取cookie的,需要人工登陆网站获取cookie再把cookie写死,如下图所示: http测试工具:http:// ...

  5. C#模拟Http与Https请求框架实例

    using System.Text; using System.Net; using System.IO; using System.Text.RegularExpressions; using Sy ...

  6. 使用ajax向后台发送请求跳转页面无效的原因

    Ajax只是利用脚本访问对应url获取数据而已,不能做除了获取返回数据以外的其它动作了.所以浏览器端是不会发起重定向的. 1)正常的http url请求,只有浏览器和服务器两个参与者.浏览器端发起一个 ...

  7. python requests 模拟登陆网站,抓取数据

    抓取页面数据的时候,有时候我们需要登陆才可以获取页面资源,那么我们需要登陆以后才可以跳转到对应的资源页面,那么我们需要通过模拟登陆,登陆成功以后再次去抓取对应的数据. 首先我们需要通过手动方式来登陆一 ...

  8. 模拟登陆,selenium,线程池

    一 . 模拟登陆案例(识别验证码)  1 . 打码平台 - 云打码 : www.yundama.com  使用步骤 : - 注册两个账户,普通用户和开发者用户 : - 登陆 普通用户查看余额 登陆开发 ...

  9. PHP实现curl和snoopy类模拟登陆方法

    Snoopy.class.php下载 方法/步骤   第一种:使用snoopy类实现模拟登陆 1.在网上下载一个Snoopy.class.php的文件   2.代码实现: <?php set_t ...

随机推荐

  1. Monitor类:Object synchronization method was called from an unsynchronized block of code.

    最近,在维护以前老系统的时候,发现了这样一个错误:Object synchronization method was called from an unsynchronized block of co ...

  2. PYTHON进阶(4)

    学习内容: 1.html简介 2.html标签 3.堡垒机 一.html简介 HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语 ...

  3. ie页面数据导入共享版

    为了解决自动输入号码的正确率,原来的版本一直采用鼠标检测的方法.但是这个方法在其他ie平台的使用不太方便.于是直接检测ie的方法.现在的这个版本完全不需要鼠标的检测.方便而且快速精准可靠. 经过作者的 ...

  4. python 在数据科学中的应用之matplotlib

    1.matplotlib模块生成直线图和散点图 >>>import matplotlib.pyplot as plt >>>year = [1950,1970,19 ...

  5. 最容易理解的对卷积(convolution)的解释

    啰嗦开场白 读本科期间,信号与系统里面经常讲到卷积(convolution),自动控制原理里面也会经常有提到卷积.硕士期间又学了线性系统理论与数字信号处理,里面也是各种大把大把卷积的概念.至于最近大火 ...

  6. IM开发基础知识补课(五):通俗易懂,正确理解并用好MQ消息队列

    1.引言 消息是互联网信息的一种表现形式,是人利用计算机进行信息传递的有效载体,比如即时通讯网坛友最熟悉的即时通讯消息就是其具体的表现形式之一. 消息从发送者到接收者的典型传递方式有两种: 1)一种我 ...

  7. Javascript高级编程学习笔记(39)—— DOM(5)Comment

    Comment类型 顾名思义,comment类型指的就是注释节点在HTML文档中的类型 也就是说平时我们在代码中的注释,在HTML解析的时候也会被解析为一类节点 让我们可以根据这些节点进行一系列的操作 ...

  8. Handshake failed due to invalid Upgrade header: null 解决方案

    Handshake failed due to invalid Upgrade header: null 解决方案 解决方案,在 Nginx ,location 中添加以下代码: proxy_set_ ...

  9. jupyter notebook的安装与基本操作

    0.前言 最近正在重温Python基础知识,为了方便练习敲代码,于是选择安装jupyter notebook作为代码编辑器. Project Jupyter exists to develop ope ...

  10. 第七篇: 消息总线(Spring Cloud Bus)

    Spring Cloud Bus 将分布式的节点用轻量的消息代理连接起来.它可以用于广播配置文件的更改或者服务之间的通讯,也可以用于监控.本文要讲述的是用Spring Cloud Bus实现通知微服务 ...