Web サイトを MVC 3 から MVC 4 にアップグレードしたところ、次のエラーが発生し始めました。
An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>
MVC 3で動作しましたが。
このコード:
Uri uri = new Uri(string.Format(
UrlTemplate,
ServiceId,
HttpUtility.UrlEncode(id),
HttpUtility.UrlEncode(org),
HttpUtility.UrlEncode(user),
HttpUtility.UrlEncode(activity),
HttpUtility.UrlEncode(module)));
using (var client = new WebClient())
{
client.DownloadDataTaskAsync(uri);
}