Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set Async="true" for all pages?

I am sending emails asynchronous using ASP.NET. I noticed that I have to set "Async = true" in the View.

The master page doesn't support this property. How can I set Async for all pages?

like image 491
alansiqueira27 Avatar asked Oct 21 '22 14:10

alansiqueira27


2 Answers

You can set it in the master page like this. Found solution here:

public abstract class MyBasePage : System.Web.UI.Page
{
    public MyBasePage()
    {
        this.AsyncMode = true;
    }
}

Then change the inheritance in the aspx.cs file to something like this:

public partial class WebForm1 : MyBasePage

It can break the system when you set the AsyncMode property in anything else then the constructor.

like image 165
Patrick Hofman Avatar answered Oct 23 '22 04:10

Patrick Hofman


Open the find dialog and enter:

Find: @Page
Replace with: @Page Async="True"

Click the Replace All button :-D To my understanding, you can't just do that automatically for everything. It needs to be defined on each and every page.

like image 35
Brian Mains Avatar answered Oct 23 '22 03:10

Brian Mains