/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { // Reload previously taken video if (appSettings.ContainsKey(videoKey)) { object filePath; if (appSettings.TryGetValue(videoKey, out filePath) && filePath.ToString() != "") { await ReloadVideo(filePath.ToString()); } } if (!appSettings.ContainsKey(usernameKey) || !appSettings.ContainsKey(passwordKey)) { loginPopUp.IsOpen = true; // so prompt the user to login usernameTxtBox.Focus(Windows.UI.Xaml.FocusState.Keyboard); } // HttpClient functionality can be extended by plugging multiple handlers together and providing // HttpClient with the configured handler pipeline. HttpMessageHandler handler = new HttpClientHandler(); handler = new PlugInHandler(handler); // Adds a custom header to every request and response message. httpClient = new HttpClient(handler); // The following line sets a "User-Agent" request header as a default header on the HttpClient instance. // Default headers will be sent with every request sent from this HttpClient instance. httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Sample", "v8")); }
internal static void CreateHttpClient(ref HttpClient httpClient) { if (httpClient != null) { httpClient.Dispose(); } // HttpClient functionality can be extended by plugging multiple handlers together and providing // HttpClient with the configured handler pipeline. HttpMessageHandler handler = new HttpClientHandler(); handler = new PlugInHandler(handler); // Adds a custom header to every request and response message. httpClient = new HttpClient(handler); // The following line sets a "User-Agent" request header as a default header on the HttpClient instance. // Default headers will be sent with every request sent from this HttpClient instance. httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Sample", "v8")); }