Please see my other MVC article.
Redirecting Users to a New Page Based on IF Logic
Similar to the article (link) MVC: Conditionally Display View link, this article illustrates how to use condition logic to change the user experience by using the controller’s default function to test if the current user is part of the Administrator role, and if so, a custom function to load a dropdown, otherwise, the user is redirected back to the homepage.
This can be a helpful deterrent to users directly accessing pages via the URL when they are not authorized to do so.
The IF statement uses my custom IsUserAdmin() function passing in the user’s current web identity provided by the browser – in this case, Internet Explorer.
The IsUserAdmin() function receives the user’s identity, strips the domain, then uses a Linq query to test the user’s identity in the Admins table.
If any records are returned, the test passes.