Windows Phone 8 HttpClient Get Method Returns Strange Results

I am developing a Windows Phone 8 application that sends some data to a server that runs it and returns a result. The server can be requested at any time in order to obtain the status of the current execution, which can be initialized, started or completed. Exit is only available if execution is complete. The user has the opportunity to check the current status of execution by clicking the "Update" button

Xaml

<Button Background="{StaticResource PhoneAccentBrush}" 
        Click="UpdateRunInfo" > Update info</Button>

This is the method

private async void UpdateRunInfo(object sender, RoutedEventArgs e)
    {
        ExecutionItem clicked = ((sender as Button).DataContext as ExecutionItem);
        HttpClientHandler handler = new HttpClientHandler();
        handler.Credentials = new NetworkCredential("username", "password");           
        HttpClient client = new HttpClient(handler);                    
        string Url = "http://somefakeurl.com/server/run/id/status";
        string _status = await client.GetStringAsync(Url);
        clicked.status = _status;
                }

So the problem is that this method only works correctly the first time it is called. After that, GetStringAsync () returns the same results as the first call, regardless of the actual state of the server.

Windows Phone, . , , # , .

, , , WP- , , GET .

HttpClient ?

+4
2

, , . L.B. client.DefaultRequestHeaders.IfModifiedSince

+3

, ( : , ). Alexei, , , .

: , , , " ".

+1

Source: https://habr.com/ru/post/1529585/


All Articles