子类继承父类,实例化子类的时候自动执行父类方法吗?
子类继承父类Mainpagepublic partial class loginpage : MainPage{ protected void Page_Load(object sender, EventArgs e) { }}父类重写OnInit方法 public class MainPage:System.Web.UI.Page { protected int a = 111; protected override void OnInit(EventArgs e) { if (Session["userName"] == null) { Response.Redirect("RegisterUI.aspx"); } base.OnInit(e); } }