now I am working on webapi but I am getting an error : The remote certificate is invalid according to the validation procedure in mvc
first I create a webapi project this is project url : https://localhost:44362/api/emps
empsController.cs
- public class empsController : ApiController
- {
- private empdbEntities db = new empdbEntities();
- // GET: api/emps
- public IQueryable
Getemps() - {
- return db.emps;
- }
- }

second I create a another project for performing a crud operation
empsController.cs
- public class empsController : Controller
- {
- // GET: emps
- public JsonResult Index()
- {
- IEnumerable
empList; - HttpResponseMessage response = globalvariable.webapiclient.GetAsync("emps").Result;
- empList = response.Content.ReadAsAsync
>().Result; //this line give an error - return Json(empList,JsonRequestBehavior.AllowGet);
- }
- }
mvcempmodel.cs
- public class mvcempmodel
- {
- public int empid { get; set; }
- public string empname { get; set; }
- public string empaddress { get; set; }
- }
- public static class globalvariable
- {
- public static HttpClient webapiclient = new HttpClient();
- static globalvariable()
- {
- webapiclient.BaseAddress = new Uri("https://localhost:44362/api/");
- webapiclient.DefaultRequestHeaders.Clear();
- webapiclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- }
- }
- empList = response.Content.ReadAsAsync
>().Result; //this line give an error
how to solve this error?
help
Jishan SiddiquePosted Aug 6, 2020, 4:32 AM
Rahul PatilPosted Aug 6, 2020, 4:39 AM