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 ...
随机推荐
- ORACLE的SQL JOIN方式大全
ORACLE的SQL JOIN方式大全 在ORACLE数据库中,表与表之间的SQL JOIN方式有多种(不仅表与表,还可以表与视图.物化视图等联结),官方的解释如下所示 A join is a que ...
- NodeJS基础入门-Event
大多数Node.js核心API都采用惯用的异步事件驱动架构,其中某些类型的对象(触发器)会周期性地触发命名事件来调用函数对象(监听器). 例如,net.Server对象会在每次有新连接时触发事件;fs ...
- 数字内置方法详解(int/long/float/complex)
一.常用方法 1.1.int 以下是Python2.7的int内置函数: 序号 函数名 作用 举例 1 int.bit_length() 二进制存储这个整数至少需要多少bit(位). >> ...
- 【markdown】 markdown 语法
介绍几个 markdown 语法学习地址和相关工具 参考链接 coding gitlab markdown offical markdown editor markdown editor2
- Altium Designer入门学习笔记2:使用原创客3D元件库
请自行淘宝购买: 元件库列表(2018年11月27日): 问题一:在项目库或已安装的库中找不到? 将"原创客"提供的文件全部添加到libraries中!"原创客" ...
- 命令行执行Qt程序
原文网址 //helloworld.cpp #include <QApplication> #include <QPushButton> int main(int argc,c ...
- PAT Basic 1076
1076 Wifi密码 下面是微博上流传的一张照片:“各位亲爱的同学们,鉴于大家有时需要使用 wifi,又怕耽误亲们的学习,现将 wifi 密码设置为下列数学题答案:A-1:B-2:C-3:D-4:请 ...
- BNU 3692 I18n 模拟
题意: 在一篇文章中,单词可以缩写.例如单词Internationalization可以缩写为I18n,缩写的两端是原单词的首尾字母,中间的数字是被省略的字母的个数. 现在给你一篇缩写的文章,输出展开 ...
- python中子进程不支持input()函数输入
错误的源代码: import socketimport threadingimport multiprocessing# 创建socketserve_socket = socket.socket(so ...
- DataContext.ExecuteQuery的两种方法调用
ExecuteQuery主要用于DataContext类直接执行SQL语句的查询,在MSDN上有两种执行方法,下面为两种方法的不同调用: 1.ExecuteQuery<TResult>(S ...