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.
Have you set the Page.Async
attribute to true
, and are you starting the asynchronous operation before the PreRenderComplete
event?
In general, you should avoid async void
. Instead of async void
, you should:
- Ensure your app is targeting 4.5 (or newer) and has
httpRuntime.targetFramework
set to 4.5 (or newer). - Set
Page.Async
totrue
. - Use
PageAsyncTask
withRegisterAsyncTask
to register asynchronous work.
solved Asynchronous operations are not allowed in this context [duplicate]