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();
-
-
- public IQueryable<emp> Getemps()
- {
- return db.emps;
- }
- }
second I create a another project for performing a crud operation
empsController.cs
- public class empsController : Controller
- {
-
- public JsonResult Index()
- {
- IEnumerable<mvcempmodel> empList;
- HttpResponseMessage response = globalvariable.webapiclient.GetAsync("emps").Result;
- empList = response.Content.ReadAsAsync<IEnumerable<mvcempmodel>>().Result;
- 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; }
- }
globalvariable.cs
- 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"));
- }
- }
here I get an error :
- empList = response.Content.ReadAsAsync<IEnumerable<mvcempmodel>>().Result;
how to solve this error?
help