SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use the WebClient Class inside a Visual Web Part (via a User Control code behind class). When I want to run the web part I always get:

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.

How can I avoid this. I know that I can set the async property to true on a normal ASP.NET page. But how can I achieve this inside SharePoint 2010.

share|improve this question

At what point in the page lifecycle are you using your WebClient object? Not inside the Render method I hope? :)

If you want to set the Async property of the page, have a look at Page.AsyncMode Property

You should be able to set this.Page.AsyncMode on the Load event (in code-behind) of your Visual WebPart.

share|improve this answer

I am developing a sharepoint webpart and trying to make async web service calls, I get the "Asynchronous operations are not allowed in this context. Page starting an asynchronous operation..." message. I was trying to add Page.AsyncMode = true; in the OnLoad of the webPart class however my Page doesnt have the AsyncMode property?

any ideas why I dont have the property ?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.