从Windows Phone 8.1发布到PHP脚本时,我收到此错误
HRESULT的异常:0x80072EFD
从控制台应用程序到PHP脚本的帖子工作正常,但Windows Phone有些不同。
在我使用ASCIIEncoding
的控制台应用中,但我在Windows Phone中找不到它,所以我使用的是HttpClient
。我在WAMP上运行Apache。
static HttpClient clientOb = new HttpClient();
static Uri uri = new Uri("http://192.168.1.4/sign_in.php");
static Dictionary<string, string> pairs = new Dictionary<string, string>();
public async void webReq()
{
try
{
pairs.Add("email", "1");
pairs.Add("password", "1");
await AsyncTask();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
txtOut.Text = ex.Message;
}
}
static async Task AsyncTask()
{
try
{
HttpFormUrlEncodedContent formContent = new HttpFormUrlEncodedContent(pairs);
HttpResponseMessage response = await clientOb.PostAsync(uri, formContent);
if (response.IsSuccessStatusCode)
{
var dialog = new MessageDialog(response.Content.ToString());
await dialog.ShowAsync();
Debug.WriteLine(dialog);
Debug.WriteLine("dialog");
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}