utilize HttpClient to generate a SSL access and generate REST access to fetch data, async programming? cool and brief
WebRequestHandler handler = new WebRequestHandler();
try
{
X509Certificate2 certificate = new X509Certificate2(System.IO.File.ReadAllBytes(ConfigurationManager.AppSettings["webapicertpath"]), ConfigurationManager.AppSettings["webapicertpwd"]); ;
handler.ClientCertificates.Add(certificate);
ServicePointManager.ServerCertificateValidationCallback =
(object sender, X509Certificate certificate1, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
{
return true;
};
}
catch
{
}
httpClient = new HttpClient(handler);
to fetch data with REST httpclient, just utilize code below:
case "get":
result = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
break;
case "post":
result = httpClient.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
break;
case "put":
result = httpClient.PutAsync(url, content).Result.Content.ReadAsStringAsync().Result;
break;
case "delete":
result = httpClient.DeleteAsync(url).Result.Content.ReadAsStringAsync().Result;
break;
default:
break;
utilize HttpClient to generate a SSL access and generate REST access to fetch data, async programming? cool and brief的更多相关文章
- Configuring Squid as an accelerator/SSL offload for Outlook Web Access
reference:http://wiki.squid-cache.org/SquidFaq/ReverseProxy/ Configuring Squid as an accelerator/SSL ...
- Access之C#连接Access
原文:Access之C#连接Access 如果是个人用的小程序的话.一般都推荐用Sqlite和Access 使用SQlite数据库需要安装SQLite驱动,详情:SQLite之C#连接SQLite 同 ...
- Access数据库SQL注入(Access SQL Injection)
一.Microsoft Office Access数据库手工注入语句 1.参数后面加 ’ .and 1=1.and 1=2看返回状态判断是否存在注入点 2.参数后面加 and exists(sel ...
- You may experience an access violation when you access an STL object through a pointer or reference in a different DLL or EXE
Symptoms When accessing an STL object created in one DLL or EXE through a pointer or reference in a ...
- nginx的access的阶段的access模块、auth_basic模块、auth_request模块及satisfy指令介绍
access 模块 示例从上向下匹配 location / { deny 192.168.1.1; allow 192.168.1.0/24; allow 10.1.1.0/16; allow 200 ...
- HttpClient忽略SSL证书
今天公司项目请求一个接口地址是ip格式的,如:https://120.20.xx.xxx/xx/xx,报一个SSL的错: 由于之前请求的接口地址都是域名地址,如:https://www.xxx.com ...
- HttpClient SSL connection could not be established error
系统从.net framework 升级到dotnet core2.1 原先工作正常的httpclient,会报SSL connection could not be established erro ...
- 你想要了解但是却羞于发问的有关SSL的一切
Everything You Ever Wanted to Know About SSL (but Were Afraid to Ask) Or perhaps more accurately, &q ...
- Oracle Applications Multiple Organizations Access Control for Custom Code
档 ID 420787.1 White Paper Oracle Applications Multiple Organizations Access Control for Custom Code ...
随机推荐
- win10中打开SQL Server 2008 的SQL Server配置管理器方法
win10找不到SQL Server配置管理器 搜索 SQLServerManager10.msc,或者运行文件:“C:\Windows\SysWOW64\SQLServerManager10.msc ...
- 洛谷P3372线段树1
难以平复鸡冻的心情,虽然可能在大佬眼里这是水题,但对蒟蒻的我来说这是个巨大的突破(谢谢我最亲爱的lp陪我写完,给我力量).网上关于线段树的题解都很玄学,包括李煜东的<算法竞赛进阶指南>中的 ...
- 【two pointers 细节题】cf1041dD. Glider
像这样细节老是打挂不行啊…… A plane is flying at a constant height of hh meters above the ground surface. Let's c ...
- [CF] 180 E. Cubes
对同类元素双指针扫描 #include<iostream> #include<cstring> #include<cstdio> #include<vecto ...
- 手机web网页的设计
Viewport(视口) 1.视口概念 描述:视口,就是视图窗口的简称,页面中视口大小实际上就是html元素的显示大小 说明:页面想要在移动端加载必须进行视口适配 如果不对页面进行调整,默认页面在 ...
- Linux下打包解压命令
tar 压缩: tar -cvjpf etc.tar.bz2 /etc //-c为创建一个打包文件,相应的-f后面接创建的文件的名称,使用了.tar.bz2后缀,-j标志使用bzip2压缩,最后面为具 ...
- october安装过程
下载代码 composer create-project october/october myoctober 准备好数据库, create database october; 配置环境于安装 php ...
- python3 发邮件 smtplib & email 库
嗨 实现了用163发送到qq的功能,遗留了两个问题: 1. 接收者list会报错:update:因为list[]会传递过去一个真的[]list,改成如下就可以了: before: maillist=[ ...
- Python9-网络编程-day30
# 由于不同机器上的程序要通信,才产生了网络# server# client# 端口 找到的程序# 在计算机上,每一个需要网络通信的程序,都会开一个端口# 在同一时间只会有一个程序占用一个端口# 不可 ...
- POJ 3057 网络流 Evacuation
题意: 有一个n×m的房间,四周每个格子要么是墙要么是门.中间部分是墙或者人. 现在所有人要从房间逃出去,每个人的速度为1,也就是每个单位时间只能向上下左右四个方向走一格. 多个人可以站在同一个格子上 ...