0
我对C#MVC项目工作的typeof表达式或数组创建表达式中,我用一个自定义授权方法控制器上的行动,但我需要通过控制器名称和行动,这是我迄今为止,但给我错误的标题,我怎么能解决这个问题呢?的属性参数必须是常量表达式,属性参数类型
public class ServiceUpdateController : Controller
{
[AuthorizeRoles(Accion = "Index", ControllerProgram = System.Web.HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString())]
// GET: ServiceUpdate
public ActionResult Index()
{
return View();
}
}
你不能把它作为在属性的参数。属性是元数据,必须在编译时知道。但是你可以在方法中获取值..显示您的代码'AuthorizeRoles'并在您需要访问它 –
@StephenMuecke做,我上传为图像 –
代码请,而不是它的图像:) –