Tuesday, 1 October 2013

I cant simply await GetStringAsync?

I cant simply await GetStringAsync?

I thought I could do i straight forward, but maybe there is something
wrong with my setup? I'm trying to download a string in my app for logging
in:
private async void DoLogin()
{
HttpClient client = new HttpClient();
string response = await
client.GetStringAsync(Config.SERVER_URL + "/Login/");
All logic is removed, im going to add headers and so on, but VS2012 will
no allow me to await that response.
I tried to follow the code from here, but in my case I only get Cannot
await 'System.Threading.Tasks.Task<string'.
Why is that? Should'nt GetStringAsync simply return me a string? It
returns a Task<string>, but do I have to wrap it in a method?

No comments:

Post a Comment