Hello Colleagues, here I am again asking colleagues for advice.
I have two methods in my application that are giving me a headache,
one reads a json file and saves it in txt and the other prints some results on the screen,
everything was working perfectly until a week ago, and suddenly an error started to appear,
These are the methods:
this is the error
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The request was aborted: Could not create SSL/TLS secure channel.
Thank you very much for the forum, a hug.
I have two methods in my application that are giving me a headache,
one reads a json file and saves it in txt and the other prints some results on the screen,
everything was working perfectly until a week ago, and suddenly an error started to appear,
These are the methods:
C#:
private void SaveDetails()
{
var url = @"https://servicebus2.caixa.gov.br/portaldeloterias/api/lotofacil";
var requisition = (HttpWebRequest)WebRequest.Create(url); // save the overall result in txt
var resposta = (HttpWebResponse)requisition.GetResponse();
using (var responseStream = resposta.GetResponseStream())
{
using (var fileStream = new FileStream(Path.Combine(diretorio + "C:\\BoaSorte\\ResultadoAtual.txt"), FileMode.Create))
{
responseStream.CopyTo(fileStream);
}
}
}
C#:
private void LoadResult()
{
var url = @"https://servicebus2.caixa.gov.br/portaldeloterias/api/lotofacil";
HttpClient lotofacil = new HttpClient();
var response = lotofacil.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
{
var listTens = response.Content.ReadAsStringAsync().Result;
var list = JsonConvert.DeserializeObject<ResultadoAtual>(listTens);
Control[] controles = ResultadoAtual;
for (int i = 0; i < controles.Length; i++)
{
int valor = Convert.ToInt32(list.listaDezenas[i]);
controles[i].Text = valor.ToString("D2");
}
var rateio = list.listaRateioPremio[0];
lblGanhadores.Text = rateio.numeroDeGanhadores.ToString("D2");
txtConcurso.Text = list.numero.ToString();
lblData.Text = list.dataApuracao.ToString();
txtDataAnterior.Text = list.numeroConcursoAnterior.ToString();
txtDataAtual.Text = list.numero.ToString();
txtDataProximo.Text = list.numeroConcursoProximo.ToString();
txtProximoConcurso.Text = list.dataProximoConcurso.ToString();
}
}
C#:
ar resposta = (HttpWebResponse)requisition.GetResponse();
Additional information: The request was aborted: Could not create SSL/TLS secure channel.
Thank you very much for the forum, a hug.