public void AddStudentToSql(StudentDetails studDetails)
        {
            //StudentDetails studDetails = JsonConvert.DeserializeObject<StudentDetails>(sdetails);
            string        constr = ConfigurationManager.ConnectionStrings["DBStudents"].ConnectionString;
            SqlConnection con    = new SqlConnection("Data Source=.;Initial Catalog=Students;Integrated Security=True");
            SqlCommand    cmd    = new SqlCommand("insert into students values (@Studentname,@SDepartment,@SAddress,@SMobile)", con);

            con.Open();
            cmd.Parameters.AddWithValue("@Studentname", studDetails.StudentName);
            cmd.Parameters.AddWithValue("@SDepartment", studDetails.SDepartment);
            cmd.Parameters.AddWithValue("@SAddress", studDetails.SAddress);
            cmd.Parameters.AddWithValue("@SMobile", studDetails.SMobile);
            cmd.ExecuteNonQuery();
            con.Close();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            StudentDetails stu = new StudentDetails
            {
                StudentName = TextBox1.Text,
                SAddress    = TextBox2.Text,
                SMobile     = TextBox3.Text,
                SDepartment = TextBox4.Text
            };
            DataContractJsonSerializer objseria = new DataContractJsonSerializer(typeof(StudentDetails));
            MemoryStream mem = new MemoryStream();

            objseria.WriteObject(mem, stu);
            string    data      = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
            WebClient webClient = new WebClient();

            webClient.Headers["Content-type"] = "application/json";
            webClient.Encoding = Encoding.UTF8;
            webClient.UploadString("http://localhost:56811/Service1.svc/ADDStudentToSql", "POST", data);
            Label1.Text = "Details saved using Rest service";
        }
 public StudentDetails ReturnSameStudent(StudentDetails studDetails)
 {
     return(studDetails);
 }