.net 模拟登陆 post https 请求跳转页面
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 请求跳转页面的更多相关文章
- 杂记-格式化Date默认格式,日期加一天,jstl判断字符类型,ajax模拟from表单后台跳转页面,jstl访问数据库并在页面显示
1.格式化Date默认格式 String str="Sun Oct 08 22:36:45 CST 2017"; SimpleDateFormat sdf = new Simple ...
- 模拟http或https请求,实现ssl下的bugzilla登录、新增BUG,保持会话以及处理token
1.增加相应httpclient 需要的jar包到工程,如果是maven工程请在pom.xml增加以下配置即可: <dependency> <groupId>org.apach ...
- 解决Nginx+Tomcat下客户端https请求跳转成http的问题
Nginx上开启https, 后端使用Tomcat, 两者间走http协议, 但发现如果tomcat应用存在跳转时, 则客户端浏览器会出现400 Bad Request的错误, 通过抓包发现原因是 ...
- http模拟登陆及发请求
首先声明下,如果服务端写入的cookie属性是HttpOnly的,程序是不能自动获取cookie的,需要人工登陆网站获取cookie再把cookie写死,如下图所示: http测试工具:http:// ...
- C#模拟Http与Https请求框架实例
using System.Text; using System.Net; using System.IO; using System.Text.RegularExpressions; using Sy ...
- 使用ajax向后台发送请求跳转页面无效的原因
Ajax只是利用脚本访问对应url获取数据而已,不能做除了获取返回数据以外的其它动作了.所以浏览器端是不会发起重定向的. 1)正常的http url请求,只有浏览器和服务器两个参与者.浏览器端发起一个 ...
- python requests 模拟登陆网站,抓取数据
抓取页面数据的时候,有时候我们需要登陆才可以获取页面资源,那么我们需要登陆以后才可以跳转到对应的资源页面,那么我们需要通过模拟登陆,登陆成功以后再次去抓取对应的数据. 首先我们需要通过手动方式来登陆一 ...
- 模拟登陆,selenium,线程池
一 . 模拟登陆案例(识别验证码) 1 . 打码平台 - 云打码 : www.yundama.com 使用步骤 : - 注册两个账户,普通用户和开发者用户 : - 登陆 普通用户查看余额 登陆开发 ...
- PHP实现curl和snoopy类模拟登陆方法
Snoopy.class.php下载 方法/步骤 第一种:使用snoopy类实现模拟登陆 1.在网上下载一个Snoopy.class.php的文件 2.代码实现: <?php set_t ...
随机推荐
- ubuntu hadoop环境搭建
安装Ubuntu系统:这个自行安装 下载jdk:我下的是1.8.0_141d的,下载好后在usr/lib下新建一个jvm的文件夹用来存放Java的文件,下载好的jdk可以在其他地方解压或者jvm里面解 ...
- 转 多租户SaaS架构
当使用Techcello框架开发云端多租户SaaS应用程序时,它继承了经过验证和测试的架构蓝图和工程结构.但开发人员仍然会保留灵活性,自由和控制权,以修改和扩展能力以适应其应用要求.此外,SaaS平台 ...
- K-DTree学习
应用于K维数据的快速查找,比如横坐标,纵坐标,价格……,本模板以16青岛区域赛K题为例 —— 三维K - D Tree 模板 我们应该都见过平衡树吧,那就是1-D树,变成k维之后,我们连续分割1 - ...
- Flume 示例
1.Syslog Tcp Source sysylog通过配置一个端口,flume能够监控这个端口的数据.如果通往这个端口发送数据可以被flume接收到.可以通过socket发送. #配置文件:sys ...
- 背水一战 Windows 10 (113) - 锁屏: 将 Application 的 Badge 通知和 Tile 通知发送到锁屏, 将 secondary tile 的 Badge 通知和 Tile 通知发送到锁屏
[源码下载] 背水一战 Windows 10 (113) - 锁屏: 将 Application 的 Badge 通知和 Tile 通知发送到锁屏, 将 secondary tile 的 Badge ...
- 谈谈npm依赖管理
引言 现在的前端开发几乎都离不开nodejs的包管理器npm,比如前端在搭建本地开发服务以及打包编译前端代码等都会用到.在前端开发过程中,经常用到npm install来安装所需的依赖,至于其中的技术 ...
- git常用命令总结——你一定会用到的几个命令
git入门看廖雪峰大神的教程即可,通俗易懂: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b806 ...
- FAIR开源Detectron:整合全部顶尖目标检测算法
昨天,Facebook AI 研究院(FAIR)开源了 Detectron,业内最佳水平的目标检测平台. 昨天,Facebook AI 研究院(FAIR)开源了 Detectron,业内最佳水平的目标 ...
- 面试题:两种方法计算n!
直接上代码package com.face.test; public class Test { /** * 面试题:递归方法计算n! */ @org.junit.Test public void di ...
- SVN切换账号
问题背景 SVN账号在登录的时候,默认是保存在个人电脑的 C:\Users\Administrator\AppData\Roaming\Subversion\auth\svn.simple\ 目录下的 ...