码迷,mamicode.com
首页 > 其他好文 > 详细

OnInit()方法

时间:2017-06-23 12:54:00      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:min   事件   summary   dmi   bpa   访问   response   base   blog   

1  public abstract class UserB2BPage : System.Web.UI.Page
2 {
3 }

web页面继承web.UI.Page;,内容为

1         //
2         // 摘要:
3         //     引发 System.Web.UI.Control.Init 事件以对页进行初始化。
4         //
5         // 参数:
6         //   e:
7         //     包含事件数据的 System.EventArgs。
8         protected internal override void OnInit(EventArgs e);

自己页面去重写它,如果自己登录存入的Cache为空,就跳转到登陆界面

 1         /// <summary>
 2         /// 获取当前登录用户
 3         /// </summary>
 4         public Base.UI.Model.UserB2B CurrentUser
 5         {
 6             get { return UserB2BCache.CurrentUser; }
 7         }
 8 
 9         protected override void OnInit(EventArgs e)
10         {
11             if (CurrentUser == null)
12             {
13                 Response.Redirect("~/Login.aspx");
14             }
15 
16             //if (CurrentUser.Disable)
17             //{
18             //    Web.UI.UserController.AdminSignOut();
19             //    Response.Redirect("~/Login.aspx");
20             //}
21 
22             /*
23             if (Program == null || !HasRight(Program.PId))
24             {
25                 Response.Write("您没有权限访问该页面");
26                 Response.End();
27             }
28              */
29         }

 

OnInit()方法

标签:min   事件   summary   dmi   bpa   访问   response   base   blog   

原文地址:http://www.cnblogs.com/Cein/p/7069093.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!