public void PostToKeyStroke() { string userid = Session[SecureProctor.BaseClass.EnumPageSessions.USERID].ToString(); string firstname = Request["firstname"]; string firstnamelastname = Request["firstNameLastName"]; BEUser objBEUser = new BEUser() { IntTransID = TransID }; BUser objBUser = new BUser(); objBUser.BGetProfileExamiKeyDetails(objBEUser); string FirstName = objBEUser.DtResult.Rows[0]["FName"].ToString(); string lastName = objBEUser.DtResult.Rows[0]["LFName"].ToString(); if (((firstname.Split(','))[0] == FirstName) && ((firstnamelastname.Split(','))[0] == lastName)) { try { var jsonObject = new JObject(); jsonObject.Add("userId", userid); jsonObject.Add("client", ConfigurationManager.AppSettings["client"]); jsonObject.Add("firstName", firstname); jsonObject.Add("firstNameLastName", firstnamelastname); var request1 = ConfigurationManager.AppSettings["apiurl"].ToString() + "examity/api/user/score"; var request = (HttpWebRequest)HttpWebRequest.Create(request1); request.Method = "POST"; request.Headers["Authorization"] = ConfigurationManager.AppSettings["authkey"]; UTF8Encoding encoding = new UTF8Encoding(); byte[] byteArray = encoding.GetBytes(jsonObject.ToString()); request.ContentType = "application/json"; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string ret = reader.ReadToEnd(); response.Close(); dynamic json = JValue.Parse(ret); if (json.statusCode == "1003") { dynamic jobj = json.scoreInfo as JObject; string obj = jobj.score; int score = Convert.ToInt32(obj); BEStudent objBEStudent = new BEStudent() { IntTransID = TransID, intExamiKeyScore = score, IntType = 26 }; BStudent objBStudent = new BStudent(); objBStudent.BUpdateExamiKEYScore(objBEStudent); objBStudent.BUpdatePLTime(objBEStudent); Response.Write("true" + "|" + objBEStudent.StrResult); } else if (json.statusCode == "1004") { //lblmsg.Text = "Invalid Profile Details Provided / Profile details not found."; Response.Write("false" + "|" + "Error in validating examiKEY"); } } } catch (WebException ex) { using (WebResponse response = ex.Response) { HttpWebResponse httpResponse = (HttpWebResponse)response; using (Stream data = response.GetResponseStream()) { string ret = new StreamReader(data).ReadToEnd(); dynamic json = JValue.Parse(ret); } } Response.Write("false" + "|" + "Error in validating examiKEY"); } } else { if (((firstname.Split(','))[0] == FirstName) & ((firstnamelastname.Split(','))[0] != lastName)) { Response.Write("false" + "|" + "First Name and Last Name do not match with profile data."); } else if (((firstname.Split(','))[0] != FirstName) & ((firstnamelastname.Split(','))[0] == lastName)) { Response.Write("false" + "|" + "First Name does not match with profile data."); } else if (((firstname.Split(','))[0] != FirstName) & ((firstnamelastname.Split(','))[0] != lastName)) { Response.Write("false" + "|" + "This does not match with your profile. Please try again."); } else { Response.Write("false" + "|" + "This does not match with your profile. Please try again."); } } }