now when I click on the send button of postman then direct access the index method that is issue I want to generate a token and then after authorize person access that method
staticvariable.cs
- public static class staticvariable
- {
- public static HttpClient webapiclient = new HttpClient();
- static staticvariable()
- {
- webapiclient.BaseAddress = new Uri("http://localhost:5718/api/");
- webapiclient.DefaultRequestHeaders.Clear();
- webapiclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- }
- }
studController.cs
- public class studController : Controller
- {
- // GET: Home
- public JsonResult Index()
- {
- IEnumerable
studlist; - HttpResponseMessage response = staticvariable.webapiclient.GetAsync("stud").Result;
- studlist = response.Content.ReadAsAsync
>().Result; - return Json(studlist,JsonRequestBehavior.AllowGet);
- }
- }
when click on the send button of the postman then after generate the token means authoriz person can access that index method
help?
Jenith ThakkarPosted Jun 14, 2020, 2:06 AM