How can I pass a List to a construtor?
It shows a message:
Error 14 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
public class CustomAuthorize : AuthorizeAttribute {
private List<string> multipleProgramID;
//constructor
public CustomAuthorize(List<string> _multipleProgramID) {
multipleProgramID = _multipleProgramID;
}
}
[CustomAuthorize(new List<string>(new string[] { ProgramList.SURVEY_INPUT, ProgramList.SURVEY_OUTPUT } ))]
[HttpPost]
public ActionResult DeleteWaterQualityItems(string sourceID, string wqID) {
// ..other code...
}
public class ProgramList {
public const string SURVEY_INPUT = "A001";
public const string SURVEY_INPUT = "A002";
}