I'm trying to do something like this:
[CustomAuthorize(Permissions = new[] { /*These are Enums */Permissions.CanChangeProducts.ToString(), Permissions.CanChangeNames.ToString()})]
public ActionResult MyMethod()
{
return View();
}
It gives the error:
Error 5 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type [...]
I've managed to put Resource string into validationattibutes, but I could'n manage to put this enum (string) array into a authorize attribute... How can I do that? Any help would be appreciated!
enum.Value | enum.Value | enum.Value
What about flags?
Like this:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Enum)]
Edit: By the way, there is very interesting answer: https://stackoverflow.com/a/270231/2524304
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With