I'm working on a project where performance is really important and i would like to disable AutoEventWireup permanently. The problem is in the fact that the page and control directives override the settings from web.config. Since there will be many collaborators on this project it will be impossible to expect everyone to disable it when creating new pages and controls (and it is true by default). Is it possible to somehow enforce this rule?
I hoped to solve this in a similar way as I did with the ViewState - setting the EnableViewState to false programmatically in the base page that all new pages inherit. But it seems there is no equivalent for AutoEventWireup.
Override SupportAutoEvents
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
this.Init += (_o, _e) => {
this.Load += (o, e) => {
Response.Write("in page handler");
};
};
}
protected void Page_Load(object sender, EventArgs e)
{
// this handler is NOT assigned to the Load event
Response.Write("assigned by ASP .Net handler");
}
protected sealed override bool SupportAutoEvents
{
get
{
return false;
}
}
}
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