Note that there are some explanatory texts on larger screens.

plurals
  1. POHow Make POST Method For registration page in Windows Phone 7
    primarykey
    data
    text
    <p>I am new to wcf services. I have made wcf restful service with GET and POST method. The Get method is running fine but POST method is not running. I have been searching the internet but cannot get anything useful. Let me tell you that i have to make a login page and a registration page. On login page i have used GET method to take login information. And to create new account i have used POST method on Registration page. When user put information on registration page, it should save the information and then use it to login.</p> <p>Following are the codes:</p> <pre><code>[OperationContract] //[WebGet(UriTemplate ="Create")] [WebInvoke(Method = "POST", UriTemplate = "Create", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] public string Create(UserProfile instance, Stream stream) { StreamReader reader = new StreamReader(stream); string data = reader.ReadToEnd(); //Return value = 1 = Success, 2 = Already Exist, 3 = Failure string i = "2"; try { using (UserProfileDataContext db = new UserProfileDataContext()) { User u = db.Users.FirstOrDefault(x =&gt; x.Email == instance.Email); if (u == null) { u = new User(); u.Email = instance.Email; u.Password = instance.Password; u.Username = instance.Username; db.Users.InsertOnSubmit(u); db.SubmitChanges(); i = "1"; } else i = "2"; } } catch (Exception ex) { i = "3"; } return i; } </code></pre> <p>this is my POST method.</p> <p>ANd this is coding on wp7 button:</p> <pre><code>private void button1_Click(object sender, RoutedEventArgs e) { if (userBox.Text == "") { MessageBox.Show("Please enter the username"); } if (passBox1.Text == "") { MessageBox.Show("Please enter the Password"); } if (emailBox.Text == "") { MessageBox.Show("Please enter the e-mail add"); } if (mobileBox.Text == "") { MessageBox.Show("Please enter the mobile number"); } MemoryStream str = new MemoryStream(); DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(UserProfile)); Uri address = new Uri("http://tx-007:87/Service1/Create"); WebClient wc = new WebClient(); wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted); wc.UploadStringAsync(address, string.Empty); NavigationService.Navigate(new Uri("/Congrat.xaml", UriKind.RelativeOrAbsolute)); } void wc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) { DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(UserProfile)); MemoryStream str = new MemoryStream(); UserProfile up = new UserProfile(); up.Username = userBox.Text; up.Password = passBox1.Text; up.Email = emailBox.Text; obj.WriteObject(str, up); str.Position = 0; StreamReader sr = new StreamReader(str); string result = sr.ReadToEnd(); MessageBox.Show(result); } </code></pre> <p>Can anyone help please?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload