Friday, 29 May 2009

Parser error : “The async attribute on the page directive is not allowed in this page”

Last week I bumped upon this error while I was trying to do an asynchrounous WCF service call from my "MS Project 2007 Web Access"-custom user control.

Turns out that you cannot set the Async="true" atttibute in the page directive af an aspx page in the Project Web Access.

The reason for this? Very simple ... the that SharePoint’s SPPageParserFilter class blocks some page directive attributes. When you use other attrubutes than the following list, you will get the error "The 'xxx' attribute on the page directive is not allowed in this page."

The list:

  • autoeventwireup
  • buffer
  • classname
  • codebehind
  • codepage
  • compileroptions
  • contenttype
  • culture
  • debug
  • description
  • enabletheming
  • enableviewstate
  • enableviewstatemac
  • errorpage
  • explicit
  • inherits
  • language
  • lcid
  • lineparagmas
  • maintainscrollpositiononpostback
  • masterpagefile
  • responsencoding
  • smartnavigation
  • strict
  • stylesheettheme
  • targetschema
  • theme
  • title

To take care of this issue we chose to have a webservice call which will handle the Ascynhrounous WCF call, and from our web user control we called this webservice method sycnhrounous.... Maybe this is not the best solution, but we really had an issue, so a quick fix was necessary here...


  1. Are there other solutions for this problem?I need to perform an asynchronous task inside a sharepoint page (it's a standard aspx page where i need async=true)

  2. Anonymous24/9/09 17:47

    Hi Jurgen,

    I am not clear about your solution. On the webservice side, you have async and sync functions waiting to be called. It means that any caller (e.g., sharepoint webpart or user control) can choose to call, async or sync. The problem for sharepoint is sharepoint web page directive rejects to have async="true". According to my understanding, your solution is on the web service side. You said you chose to have a webservice call to handle the async WCR call. I don't understand about that. Can you explain a little bit more details about your solution? Thanks.


  3. @PC. To make a very short explanation:

    1. I have my sharepoint aspx page containing my webparts (usercontrols in this case).
    2. I have a webservice running, with a webmethod that can be called from sharepoint user control.
    3. This webservice connects to the WCF WindowsService running on the App Server.
    4. The webmethod executes the WCF call async.

    In fact this means I call the WebMethod synchronously from sharepoint side, but in fact I just handle it async in the WS.
    Maybe it is not the best workaround, but in our case it was the most fitting.