1

I've upgraded my website to MVC 4 from MVC 3 and started experience this error:

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" %>

Though it worked in MVC 3.

This code:

            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
  • So, did you mark your pages with Async=true, and did it work then? Commented Nov 19, 2012 at 9:31
  • No, I didn't mark them. It wasn't neccesary for MVC 3. How can I do it? Commented Nov 19, 2012 at 9:34
  • Maybe the problem is with the .NET Framework 4.5. Because at the previous time (with MVC 3) I didn't experience any of these problems Commented Nov 19, 2012 at 9:42
  • As the error message says: ensure that the Page is marked <%@ Page Async="true" %>. This is a feature new to MVC 4. Commented Nov 19, 2012 at 9:52

1 Answer 1

2

As the error message says: ensure that the Page is marked <%@ Page Async="true" %>. This is a feature new to MVC 4.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.