C#中重写OnInit,在SL中如何实现【在线等】
- C# code
/// <summary> /// 资料管理页面基类 /// </summary> public class AdminWebPageBase : PageBase { protected override void OnInit(EventArgs e) { //检测用户登录状态 if (HttpContext.Current.Session["CurrentUser"] == null) { HttpContext.Current.Response.Redirect("~/docmanage/framenotlogin.aspx"); } base.OnInit(e); } }
[解决办法]
你可以采用写一个公共父类BasePage.cs的方式,使用这个类继承页面基类,然后其他页面调用这个BasePage.cs类即可。