An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
Posted on: 2012-11-09
If you are trying to use a static string in an attribute for an action inside a Asp.Net MVC's controller, you will get a strange error.
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
This is because you are using static string instead of constant.
public static string AdministratorRole="admin";
The code below works because it's a public const string
instead of a public static string.
public const string AdministratorRole="admin";