Skip to content

Instantly share code, notes, and snippets.

@gsedubun
Created January 27, 2020 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsedubun/cf5371ce1db6de4635c57a9a3096164e to your computer and use it in GitHub Desktop.
Save gsedubun/cf5371ce1db6de4635c57a9a3096164e to your computer and use it in GitHub Desktop.
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