我正在尝试从 Web API 使用客户端的 Web 服务,以下是我们目前用来绕过 SSL 证书的代码
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
它运行良好,直到他们最终禁用了 TLS 1.0 和 TLS 1.1。现在我们添加了以下代码以使用 TLS 1.2 进行客户端服务器连接
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
现在我收到“请求已中止:无法创建 SSL/TLS 安全通道。” 仅当我第一次点击 API 时出错,然后如果我连续点击 API 就会得到结果,如果我等待一分钟左右的时间,再次仅第一次出现相同的错误。
我需要将以下 Json 字符串转换为 DataTable。
{
"pnr":"1234567890",
"train_num":"12311",
"train_name":"HWH DLIKLK MAI",
"doj":"23-12-2013",
"from_station":
{
"code":"DLI",
"name":"Delhi"
},
"to_station":
{
"code":"KLK",
"name":"Kalka"
}
}
Run Code Online (Sandbox Code Playgroud)
在数据表中我需要显示
train_num
train_name
doj
from_station(name only)
to_station(name only)
Run Code Online (Sandbox Code Playgroud)
到目前为止我所拥有的是,
public class Train
{
public string train_num { get; set; }
public string train_name { get; set; }
public string doj { get; set; }
public from_station from_station { get; set; }
public to_station to_station { get; set; }
}
public class from_station
{
public string code { get; …Run Code Online (Sandbox Code Playgroud) 我想将本地化日期格式化为格式。例如 yyyyMMdd OR ddMMyyyy OR MMddyyyy 基于系统日期格式。以下是我尝试过的方法,它正在工作,但需要有效的方法来做到这一点。
DateTime.Now.ToLocalTime().Date.ToString().Replace("/","").Replace(":","").Replace(" ","").Replace("-","")
Run Code Online (Sandbox Code Playgroud)