首页 > 代码库 > AOP返回控制器一个实体调用
AOP返回控制器一个实体调用
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Web.Mvc; 6 using Common; 7 using QianLiFaAuto.User.DAL; 8 using QianLiFaAuto.User.IDAL; 9 using QianLiFaAuto.User.Model;10 11 namespace AOP12 {13 14 15 [AttributeUsage(AttributeTargets.Method)]16 public class AdminUser : FilterAttribute, IActionFilter, IAuthorizationFilter17 {18 /// <summary>19 /// 会员验证方法20 /// </summary>21 /// <param name="filterContext"></param>22 public void OnActionExecuting(ActionExecutingContext filterContext)23 {24 int UserID;25 int.TryParse(CommonCookie.GetCookie("AdminUserID"), out UserID);26 if (CommonCookie.GetCookie("AdminUserID") == null)27 {28 filterContext.HttpContext.Response.Redirect("/user/adminlogin");29 }30 Admin model = new Admin();31 model.AdminID = UserID;32 model.Name = CommonCookie.GetCookie("AdminUserName");33 filterContext.Controller.ViewBag.Name = model.Name;34 35 if (filterContext.ActionParameters.ContainsKey("user"))36 {37 filterContext.ActionParameters["user"] = model;38 39 }40 }41 42 /// <summary>43 /// 44 /// </summary>45 /// <param name="filterContext"></param>46 public void OnAuthorization(AuthorizationContext filterContext)47 {48 }49 50 /// <summary>51 /// 52 /// </summary>53 /// <param name="filterContext"></param>54 public void OnActionExecuted(ActionExecutedContext filterContext)55 {56 }57 }58 }
AOP返回控制器一个实体调用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。