In my web.config I have the following:
<appSettings>
<add key="webpages:Enabled" value="false" />
<add key="authorizedUsers" value="jeff,jason,bob"/>
</appSettings>
In my _Layout.cshtml I have the following:
@{
List<String> authList = new List<string>();
authList = System.Web.Configuration.WebConfigurationManager.AppSettings["authorizedUsers"].Split(',').ToList();
if (authList.Any(u=>u == this.User.Identity.Name))
{
<li>@Html.ActionLink("Admin", "Index", "Admin")</li>
}
}
When I run this I get Object reference not set to an instance of an object.
What do I need to do to get this to work?