I am using Asp.Net/C# to build an application.I am using Forms Authentication.I have a requirement such that many of my authenticated (not anonymous) users are restricted to certain page functionalities or user interface.I guess the Login Control could be used for only Authenticated vs Anonymous users.So my question is when I know that certain page component is to be hidden from particular authenticated users , how do I go about it.Do you think I need to use this on the page_load event to hide the components for the pages which have such requirements.
// Is this Tito visiting the page?
string userName = User.Identity.Name;
if (string.Compare(userName, "Tito", true) == 0)
// This is Tito, SHOW the Delete column
FilesGrid.Columns[1].Visible = true;
else
// This is NOT Tito, HIDE the Delete column
FilesGrid.Columns[1].Visible = false;
Are there better approaches to accomplish this.Any help is much appreciated.Thanks
Here you can use the Membeship User class and RolePrincipal to separate the users.
So you make and place your user in different membership names, and then you show them different controls that are depend on the membership role.
Some links:
http://msdn.microsoft.com/en-us/library/ff648345.aspx
http://msdn.microsoft.com/en-us/library/system.web.security.roleprincipal.isinrole.aspx