diff --git a/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs index 8800886d..e85a87b6 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs @@ -67,6 +67,15 @@ namespace CampusAppWP8.Pages.Links this.clubLinkFeed.LoadData(); } + /// + /// Override the OnNavigatedTo method + /// + /// Arguments of navigation + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + this.clubLinkFeed.SaveData(); + this.commonLinkFeed.SaveData(); + } #endregion #region private @@ -114,9 +123,9 @@ namespace CampusAppWP8.Pages.Links if (this.loadingFeeds < 1) { - this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; } - this.commonLinkFeed.SaveData(); + } /// @@ -129,8 +138,7 @@ namespace CampusAppWP8.Pages.Links if (this.loadingFeeds < 1) { this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; - } - this.clubLinkFeed.SaveData(); + } } /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs index ebb30a38..665a004f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/HttpRequest.cs @@ -17,13 +17,12 @@ namespace CampusAppWP8.Utility /// public class HttpRequest { - #region Members + #region Member /// - /// the WebClient, which send the requests + /// BaseAddress of the webclient /// - private WebClient client; - + private string baseAddress; #endregion #region Constructor @@ -33,7 +32,6 @@ namespace CampusAppWP8.Utility /// public HttpRequest() { - this.client = new WebClient(); } /// @@ -42,8 +40,7 @@ namespace CampusAppWP8.Utility /// the url of the HttpRequest base address public HttpRequest(Uri apiBaseAddress) { - this.client = new WebClient(); - this.client.BaseAddress = apiBaseAddress.AbsoluteUri; + baseAddress = apiBaseAddress.AbsoluteUri; } #endregion @@ -58,8 +55,9 @@ namespace CampusAppWP8.Utility /// callback method public void HttpGet(Uri url, Action action) { - this.client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(action); - this.client.DownloadStringAsync(url); + WebClient client = new WebClient(); + client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(action); + client.DownloadStringAsync(url); } /// @@ -75,7 +73,7 @@ namespace CampusAppWP8.Utility paramterStr += parameter.ToString(); } - string getUrlStr = this.client.BaseAddress + "?" + paramterStr; + string getUrlStr = baseAddress + "?" + paramterStr; return new Uri(getUrlStr, UriKind.Absolute); } @@ -190,8 +188,9 @@ namespace CampusAppWP8.Utility /// Data which are sending to the HttpRequest private void UploadData(Uri url, Action action, string method, string data) { - this.client.UploadStringCompleted += new UploadStringCompletedEventHandler(action); - this.client.UploadStringAsync(url, method, data); + WebClient client = new WebClient(); + client.UploadStringCompleted += new UploadStringCompletedEventHandler(action); + client.UploadStringAsync(url, method, data); } #endregion