2013-02-09 5 views
0

입니다. http get 요청을 사용하여 서버에 위치 데이터를 보내는 간단한 앱을 만들고 있습니다. 문제는 positionchanged 이벤트 처리기 안에 있다는 사실에도 불구하고 요청이 처음으로 만들어진 것입니다.도착 위치는 get

여기 내 코드입니다. 나는 그것이 무엇이 잘못되었는지를 알 수 없다.

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(); 
     } 

    } 
} 

답변

2

내가 게시 한 코드에서 호출간에 변경되지 않는 URI는 처음으로 캐시에서 해결된다고 말할 수 있습니다. 난 당신이 매개 변수를 추가하고 각 호출 (예 :보고 싶은 위치)와 함께 변경 값을주는 오래된 해킹을 사용하는 것이 좋습니다.

+0

그건 내가 예측하지 못한 것입니다. 나는 그것이 작동하는지 테스트 할 URL을 고정 시켰고 이것은 나를 실패시켰다. – kechapito

+0

웹 응용 프로그램 초기에 캐시는 내 존재의 단점이었습니다. HTML 메타 태그와 지시어에 URL (이미 제안한대로)을 흐리게 처리하는 것에서부터 금지하는 것에 이르기까지 여러 가지 방법이 있습니다. URL을 짧게 표시하는 것은 추악하지만 신뢰할 만합니다. 아래쪽은 브라우저 캐시를 압축합니다. –