Windows phone 7 使用get发送位置

Windows phone 7 使用get发送位置,windows-phone-7,Windows Phone 7,我正在制作一个简单的应用程序,使用http get请求将位置数据发送到服务器。 问题在于,尽管请求位于positionchanged事件处理程序中,但请求仅在第一次发出 这是我的密码。我找不出它有什么毛病 using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using Sys

我正在制作一个简单的应用程序,使用http get请求将位置数据发送到服务器。 问题在于,尽管请求位于positionchanged事件处理程序中,但请求仅在第一次发出

这是我的密码。我找不出它有什么毛病

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Device.Location;

namespace kechap
{
    public partial class MainPage : PhoneApplicationPage
    {
        GeoCoordinateWatcher gw = new GeoCoordinateWatcher();

        Uri url = new Uri("http://127.0.0.1:5000/upload/1e3fae069dd62fa1641183cd77092ed2053a0e75/1/2");


        // Constructor
        public MainPage()
        {
            InitializeComponent();
            gw.MovementThreshold = 10;
            gw.PositionChanged += (s, e) =>
            {
                MyMap.Center = e.Position.Location;
                MyPushpin.Location = e.Position.Location;

                WebClient wc = new WebClient();

                wc.OpenReadAsync(url);
                wc.OpenReadCompleted += (ss, ee) =>
                {
                };          
            };

            gw.Start();
        }

    }
}

我猜,URI在您发布的代码中在调用之间不会改变,它在第一次调用后从缓存中解析。我建议您使用一种古老的技巧,即附加一个参数,并给它一个随每次调用而变化的值(例如您似乎想要报告的位置)。

这是我没有预料到的。我修复了url以测试它是否有效,但我失败了。在web应用程序的早期,缓存是我存在的祸根。有很多方法可以阻止它,从篡改URL(正如我已经建议的)到各种各样的HTML元标记和指令。篡改URL虽然丑陋但可靠。缺点是它会使浏览器缓存膨胀。