internal HttpResponseMessage GetRegistered(string modelString) { try { HttpResponseMessage response; RegisterGamerInfo registerGamerInfo = JsonConvert.DeserializeObject <RegisterGamerInfo>(Encrypt.DecryptString(modelString, "enigma")); RegistrationStatus registrationStatus = Facades.RegisterFacade.RegisterGamer(registerGamerInfo.Uname, registerGamerInfo.EmailId, registerGamerInfo.Password); if (registrationStatus.ErrorCode == 200) { response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(registrationStatus), Encoding.ASCII, "application/json") }; } else { response = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(JsonConvert.SerializeObject(registrationStatus), Encoding.ASCII, "application/json") }; } return(response); } catch (Exception e) { RegistrationStatus regStatus = new RegistrationStatus(502, "Internal Server Error"); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(JsonConvert.SerializeObject(regStatus), Encoding.ASCII, "application/json") }; return(response); } }
protected void regBtn_Click(object sender, EventArgs e) { using (var client = new HttpClient()) { string passwordHashed = Encoding.ASCII.GetString(new SHA256Managed().ComputeHash(Encoding.ASCII.GetBytes(passtxt.Text))); RegisterGamerInfo regInfo = new RegisterGamerInfo(unametxt.Text, passwordHashed, emailtxt.Text); string sendingLink = JsonConvert.SerializeObject(regInfo); Task <HttpResponseMessage> responseTask = client.PostAsync(uri, new StringContent(Encrypt.EncryptString(sendingLink, "enigma"), Encoding.UTF8, "application/json")); HttpResponseMessage response = responseTask.Result; string val = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Success')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + val + "')", true); } } }