Created
January 27, 2020 09:03
-
-
Save gsedubun/cf5371ce1db6de4635c57a9a3096164e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Security; | |
using System.Security.Cryptography.X509Certificates; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
using RestSharp; | |
using schoolapp.Models; | |
namespace schoolapp.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
private readonly ILogger<HomeController> _logger; | |
public HomeController(ILogger<HomeController> logger) | |
{ | |
_logger = logger; | |
} | |
public IActionResult Index() | |
{ | |
RestClient client = new RestClient("https://localhost:5001"); | |
client.RemoteCertificateValidationCallback = new RemoteCertificateValidationCallback(Remo); | |
RestRequest req = new RestRequest(Method.GET); | |
req.Resource = "/hello/index"; | |
IRestResponse resp = client.Execute(req,Method.GET); | |
ResultModel m =new ResultModel(); | |
m.StatusText=resp.StatusDescription; | |
m.ResponseCode = resp.StatusCode; | |
return View(m); | |
} | |
private bool Remo(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) | |
{ | |
return true; | |
} | |
} | |
public class ResultModel | |
{ | |
public string StatusText { get; set; } | |
public HttpStatusCode ResponseCode { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment