Every bit of research on this topic is showing how to do this tasks with MVC, my project is MVP webforms based. I have the authentication done, but is there a pattern or strategy to best do authorization?
Such as checking for hotlinking on specific pages against a user's role, or hiding ASP controls given a role.
Currently I'm doing things like:
if(user.Roles.Contains("Admin")){
lnkAdmin.Visibility = true;
}
And I don't think that's very clean or maintainable, is there a better way to do these things?
The Web Forms way of making specific controls available only to certain roles is to use a LoginView control. Example from the documentation:
To prevent users not in certain roles from accessing pages, you can use the location elements in your web.config file. Again, another example from the documentation:
Similarly, it can be role based.