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
- {
-
- public JsonResult Index()
- {
- IEnumerable<student> studlist;
- HttpResponseMessage response = staticvariable.webapiclient.GetAsync("stud").Result;
- studlist = response.Content.ReadAsAsync<IEnumerable<student>>().Result;
- return Json(studlist,JsonRequestBehavior.AllowGet);
- }
- }
what i want to the
when click on the send button of the postman then after generate the token means authoriz person can access that index method
help?