我正在尝试在Windows Phone 8.1中使用一个简单的应用程序。我有一个按钮,并在第一次点击它发送请求通过PHP中的URL将数据插入数据库。在第二次单击它通过PHP中的另一个URL删除数据库中同一个表中的数据。当我第一次运行它。它向我发送了以下来自httpclient响应的响应
StatusCode:200, ReasonPhase:'ok',
version:0.0,content:
System.Net.Http.streamContent,headers:
{
Date:thu,04 jun 2015 08:29:50 GMT
server:apache
server:phusion_passage/4.0.10
server: mod_bwlimited/1.4/5
server:mod_fcgid/2.3.9
X-powered-by:PHP/5.4/5.4.36
Keep-Alive:timeout=3,max=30
connection:keep-alive
Transfer-encoding:chunked
content-Type:text/html
}
并且在第二次点击时我也会得到相同的删除回复。如果我再次按下按钮我会得到以下消息:
StatusCode:200, ReasonPhase:'ok',
version:0.0,content:
System.Net.Http.streamContent,headers:
{
X-powered-by:PHP/5.4/5.4.36
Keep-Alive:timeout=3,max=30
Transfer-encoding:chunked
content-Type:text/html
}
显然没有数据插入数据库。
我正在紧急启动它,因为这只是一个大项目的一小部分。 我的代码如下:
声明:
url = "http://demo.in/customer_info.php?";
url_delete = "http://demo.in/delete_noti.php?device_id=";
data1 = url + "device_id=4000";
data_delete = url_delete + "4000";
方法:
private async void sendData(string data)
{
// MessageBox.Show(data1);
using (HttpClient hc = new HttpClient())
{
var response = await hc.GetAsync(data);
MessageBox.Show(response.ToString());
hc.Dispose();
}
}
private async void deleteData(string data)
{
//MessageBox.Show(url_delete1);
using (HttpClient hc = new HttpClient())
{
var response = await hc.GetAsync(data);
//MessageBox.Show(hc1.ToString());
MessageBox.Show(response.ToString());
hc.Dispose();
}
}
用法:
private void btn_click(object sender, RoutedEventArgs e)
{
if (count == 0)
{
sendData(data1);
(sender as Button).Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(225, 247, 98, 15));
MessageBox.Show("sending");
// suspend(a);
count = 1;
}
else
{
deleteData(url_delete);
(sender as Button).Background = new SolidColorBrush(Colors.Black);
MessageBox.Show("deleting");
count = 0;
}
}
答案 0 :(得分:0)
正如@Null Pointer所说,这可能是一个缓存问题。
您可以按照他的说法在网址中添加随机参数,或者如果您没有或者无法在网址中添加参数,则可以添加此行代码以忽略缓存:
also accepted
$mail->Port = 587; */