Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以重写控制器(ASP.NET MVC3)中定义的自定义属性参数?_Asp.net_Asp.net Mvc 3_Security - Fatal编程技术网

是否可以重写控制器(ASP.NET MVC3)中定义的自定义属性参数?

是否可以重写控制器(ASP.NET MVC3)中定义的自定义属性参数?,asp.net,asp.net-mvc-3,security,Asp.net,Asp.net Mvc 3,Security,我在控制器中定义了一些修改文件内容的操作(当然,我不直接从控制器中修改,但该控制器从模型中调用方法)。在该函数上,我添加了一个自定义属性,其中提到必须具有管理员权限 该操作看起来像: [CustomAttribute(MustBeAdmin = true)] public ActionResult ModifyFile(){ ... } public class CustomAuttribute: AuthorizeAttribute { public bool MustBeAdm

我在控制器中定义了一些修改文件内容的操作(当然,我不直接从控制器中修改,但该控制器从模型中调用方法)。在该函数上,我添加了一个自定义属性,其中提到必须具有管理员权限

该操作看起来像:

[CustomAttribute(MustBeAdmin = true)]
public ActionResult ModifyFile(){
  ...
}
public class CustomAuttribute: AuthorizeAttribute 
{
   public bool MustBeAdmin {get;set;}

   protected override void HandleUnauthorizedRequest( AuthorizationContext filterContext) {
       if ( filterContext.RequestContext.HttpContext.Session["user"] == null ) { ... }
       else { ... // check if is need admin rights and current has this right then continue else go to default route }
   }
}
CustomAttribute
看起来像:

[CustomAttribute(MustBeAdmin = true)]
public ActionResult ModifyFile(){
  ...
}
public class CustomAuttribute: AuthorizeAttribute 
{
   public bool MustBeAdmin {get;set;}

   protected override void HandleUnauthorizedRequest( AuthorizationContext filterContext) {
       if ( filterContext.RequestContext.HttpContext.Session["user"] == null ) { ... }
       else { ... // check if is need admin rights and current has this right then continue else go to default route }
   }
}
为了安全起见,我想问您,是否有人可以从代码外部将
MustBeAdmin
参数设置为false值

如果是,如何预防

谢谢