Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

HttpClient .net Core add Certificate

Module m = Assembly.GetEntryAssembly().GetModules()[0];
using (var cert = m.GetSignerCertificate())
using (var cert2 = new X509Certificate2(cert))
{
   var _clientHandler = new HttpClientHandler();
   _clientHandler.ClientCertificates.Add(cert2);
   _clientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
   var myModel = new Dictionary<string, string>
   {
       { "property1","value" },
       { "property2","value" },
   };
   using (var content = new FormUrlEncodedContent(myModel))
   using (var _client = new HttpClient(_clientHandler))
   using (HttpResponseMessage response = _client.PostAsync($"{url}/{controler}/{action}", content).Result)
   {
       response.EnsureSuccessStatusCode();
       string jsonString = response.Content.ReadAsStringAsync().Result;
       var myClass = JsonConvert.DeserializeObject<MyClass>(jsonString);
    }
}
Comment

HttpClient .net Core add Certificate

Module m = Assembly.GetEntryAssembly().GetModules()[0];
using (var cert = m.GetSignerCertificate())
using (var cert2 = new X509Certificate2(cert))
{
   var _clientHandler = new HttpClientHandler();
   _clientHandler.ClientCertificates.Add(cert2);
   _clientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
   var myModel = new Dictionary<string, string>
   {
       { "property1","value" },
       { "property2","value" },
   };
   using (var content = new FormUrlEncodedContent(myModel))
   using (var _client = new HttpClient(_clientHandler))
   using (HttpResponseMessage response = _client.PostAsync($"{url}/{controler}/{action}", content).Result)
   {
       response.EnsureSuccessStatusCode();
       string jsonString = response.Content.ReadAsStringAsync().Result;
       var myClass = JsonConvert.DeserializeObject<MyClass>(jsonString);
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# convert bitmap to image 
Csharp :: messagebox yes no c# 
Csharp :: why to make private fields readonly in c# 
Csharp :: change physics material unity 
Csharp :: c# linq join mutiple 
Csharp :: how to set the server url in dotnet core 
Csharp :: c# arrays 
Csharp :: ssml 
Csharp :: Transpose Matrix C Sharp 
Csharp :: array to object c# 
Csharp :: .net using appsettings variables 
Csharp :: js if empty then 0 
Csharp :: how to create a string in c# 
Csharp :: Reporting Progress from Async Tasks c# 
Csharp :: cloudmailin c# 
Csharp :: dataannotations for currency in c# 
Csharp :: jq map over array 
Csharp :: lock a cache in asp.net 
Csharp :: deferred rendering unity 
Csharp :: what is napalm made of 
Csharp :: project camera view to texture 
Csharp :: c# multipthreading 
Csharp :: mvc remote validation additional table 
Csharp :: asp.net list size 
Csharp :: hierachical table to c# class 
Csharp :: qget ViewSchedule revit api 
Csharp :: OIUJHKJHSKAL::KSAJ 
Csharp :: C# Move Camera Over Terrain Using Touch Input In Unity 3D 
Csharp :: C# if (if-then) Statement 
Csharp :: wpf clock conrt 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =