Solving the “Asynchronous operations are not allowed… ” exception

While doing some asynchronous coding in a code behind file, I ran across a System.InvalidOperationException exception, with this message:

Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event.

Luckily, the solution was very easy. I added the tag Async=”true” to the Page declaration, and that was it:

<%@ Page Language="C#" Async="true" ...  %> 
Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: