ASP.NET Web method with asynchronous call on server side
<p>I have a ASP.NET web service (.asmx) that is called from client side with JavaScript.</p>

<p>Let say that the web service has a web method with the name "GetTotalMovies()". This web method will return an int with the number of movies in a specific channel on YouTube.</p>

<p>When this web method is called it will do a http request to the YouTube REST API to get how many movies a specific channel has and then return it to the client that called "GetTotalMovies()".</p>

<p>The call the the YouTube REST API is pretty slow so I want to do this asynchronous with this "pseude" code:</p>

<pre><code>private async Task&lt;int&gt; GetTotalMoviesFromYouTubeApi()
{
     using(var client = new WebClient()) {
         return await client.DownloadStringAsync(_uri);
     }
}
</code></pre>

<p>And here is my web method that is called from the client:</p>

<pre><code>[WebMethod]
public int GetTotalMovies() {
    return (int)await PostDataToYouTubeApi(s);
}
</code></pre>

<p>This will not work since I use the await keyword in the method GetTotalMovies when the method is not async.</p>

<p>But if I change the method to async I need to return Task from the method. And when I change this it will be really messy when JavaScript call this function.</p>

<p>I am stuck, I don't really now how to go further. Help! :)</p>