Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HttpClient client = new HttpClient();
- client.BaseAddress = new Uri("http://localhost:57752");
- HttpResponseMessage response = client.GetAsync("api/Auth/Login/" + user.Username + "/" + user.Password).Result;
- JsonResult result = null;
- if (response.IsSuccessStatusCode)
- {
- result = response.Content.ReadAsAsync<JsonResult>().Result;
- JavaScriptSerializer json_serializer = new JavaScriptSerializer();
- User validUser=
- (User)json_serializer.DeserializeObject(result.Data.ToString());//Throws Exp.
- }
- [System.Web.Http.Route("api/Auth/Login/{username}/{password}")]
- public ActionResult Login(string username, string password)
- {
- User loginuser = new Models.User() { Username = username, Password = password };
- try
- {
- loginuser = context.UserRepository.checkUserExist(loginuser);
- return new JsonResult
- {
- Data = loginuser,
- JsonRequestBehavior = JsonRequestBehavior.AllowGet
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement