public HttpResponseMessage RegisterUser(HttpRequestMessage request) { try { if (request.Content.Headers.ContentType.MediaType != "application/json") { return(new HttpResponseMessage(HttpStatusCode.UnsupportedMediaType)); } var jsonData = request.Content.ReadAsStringAsync().Result; var data = JObject.Parse(jsonData); var username = (string)data["username"]; var password = (string)data["password"]; if (!loginModule.RegisterUser(username, password)) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } return(new HttpResponseMessage(HttpStatusCode.Accepted)); } catch (Exception e) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } }
protected void register_Click(object sender, EventArgs e) { var regUsername = this.RegUsername.Text; var regPassword = this.RegPassword.Text; if (loginModule.RegisterUser(regUsername, regPassword)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Registration Successful');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Registration Failed');", true); } }