Is it possible within my code-behind file to set the asynchronous mode of the page directive.
I have no way of directly modifying the <%@Page %>
attribute and and struggling to find a way to implement this in my code-behind.
I have tried in my Page_Load method to add Page.AsyncMode = true
, but it returns the following error:
is inaccessible due to its protection level
Is there any way to do this? Without being able to directly modify the master page?
No, you cannot change the asynchronous mode of a page in the code-behind. An asynchronous page implements the IHttpAsyncHandler
interface, and there is no way to change the interfaces implemented by your page after the .aspx file has been compiled by ASP.NET and your code is running.
Setting the Page.AsyncMode
property will not change the asynchronous mode. Its purpose is to let controls on the page know whether the page is running in asynchronous mode or not, so tampering with the property may cause controls to malfunction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With