不能返回正确的方法后的结果 [英] not return correct post method result

查看:164
本文介绍了不能返回正确的方法后的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用PHP /我的SQL

I'm trying to make an application in windows phone 8 login functionality using php/my sql

我有以下PHP脚本来使的Windows Phone 8的登录功能的应用程序:

i have following php script :

在我的Windows Phone C#的单击事件我写了下面的事情:

in my windows phone c# click event i wrote following things :

 private void btnLogin_Click(System.Object sender, System.Windows.RoutedEventArgs e)
        {

            Uri uri = new Uri(url, UriKind.Absolute);

            StringBuilder postData = new StringBuilder();
            postData.AppendFormat("{0}={1}", "email", HttpUtility.UrlEncode("Test@test.com"));
            postData.AppendFormat("&{0}={1}", "pwd1", HttpUtility.UrlEncode("password"));

            WebClient client = default(WebClient);
            client = new WebClient();
            client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            client.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();

            client.UploadStringCompleted += client_UploadStringCompleted;
            client.UploadProgressChanged += client_UploadProgressChanged;

            client.UploadStringAsync(uri, "POST", postData.ToString());

            prog = new ProgressIndicator();
            prog.IsIndeterminate = true;
            prog.IsVisible = true;
            prog.Text = "Loading....";
            SystemTray.SetProgressIndicator(this, prog);

        }

        private void client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
        {
            //Me.txtResult.Text = "Uploading.... " & e.ProgressPercentage & "%"
        }

        private void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            if (e.Cancelled == false & e.Error == null)
            {
                prog.IsVisible = false;

                string[] result = e.Result.ToString().Split('|');
                string strStatus = result[0].ToString();
                string strMemberID = result[1].ToString();
                string strError = result[2].ToString();

                if (strStatus == "0")
                {
                    MessageBox.Show(strError);
                }
                else
                {
                    NavigationService.Navigate(new Uri("/DetailPage.xaml?sMemberID=" + strMemberID, UriKind.Relative));
                }

            }
        }



我verfity电子邮件和密码是正确的,在C#代码,我说,但最终我总是得到这样的消息: e.Result =不正确的用户名或密码

推荐答案

我下载你的应用程序样本,对其进行了测试。当我考试系统的应用程序是使用招发送请求时,它接缝该应用程序在发送正是你所提供的信息。所以,你的POST方法是做什么工作。

I downloaded your app sample and tested it. When i examin the request the app is sending using Fiddler, it seams that the app is sending the exactly the info you provided. So your POST method is doing it job.

我测试,甚至从内部提琴手重新发送请求,并得到相同的结果,即得。正确的POST信息,但不对e.Result(错误的用户名或密码)。

I tested even to resend the request from inside Fiddler and get the same result, ie. Correct POST info but wrong e.Result (Incorrect username or password).

这一切让我觉得,这个问题是不是在你的应用程序或比其他Web客户端服务器端。请关注一下吧。

All this makes me feel that the problem is not in your app or WebClient other than server side. Please look at it.

通过使用原因的WebClient的方式?你可以HttpWebRequest的用户或HttpClient的。

By the way why using WebClient? you can user HttpWebRequest or HttpClient.

这篇关于不能返回正确的方法后的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆