How can I get a value from the ASP.NET MVC 5 web.config
into a controller method?
At first I put the value into a string and that works:
public const string ADUser = System.Configuration.ConfigurationManager.AppSettings["ADUser"].ToString();
There are many examples on Stackoverflow with
public const string
but in my case it doesn't work.
[Authorize(Users = ADUser)]
public ViewResult Index()
{
var user = db.user
.Where(m => m.Id != 0)
.ToList();
return View(user);
}
Here is the exception. It belong to the [Authorize(Users = ADUser)]
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type enum Description
Does anybody have any idea?