Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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