1

我已将我的网站从 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);
        }
4

1 回答 1

2

正如错误消息所说:确保页面被标记<%@ Page Async="true" %>。这是 MVC 4 的新特性。

于 2012-11-19T10:07:09.277 回答