I have the following code block: -
using System.ComponentModel.DataAnnotations;
public class NewsItem
{
[RegularExpression(System.Configuration.ConfigurationSettings.AppSettings["UrlRegEx"], ErrorMessage = "Invalid link")]
public string Url { get; set; }
}
This returns the error "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type".
How can I give the value in the first parameter of a RegularExpression attribute. I want to give the values from Web.Config variables. I am using this code in the Model class of EF.