I have a similar situation that @IndigoMontoya has -- I found his question here https://forums.asp.net/t/2056082.aspx?Giving+User+Access+On+Menu+by+Menu+Page+by+Page -- and I see that @Li Wang gave him a great solution to his issue. Mine is similar, while different at the same time, so let me explain. Now my situation is different than the one I hotlinked in here as the fact that I do not have aspx page names stored in the database, my "get permission" sql call only returns results like so: so a further breakdown would be pageID is the actual page number pageID 1 = pageone pageID 2 = page2 etc. userID is of course the userID and permission is 1 for yes, 0 for no. So userID 1 has full access to everything, and userID 2 only has certain access. (Now of course this is a super small subset of what is actually being done, but enough to show the pain I am having coming up with an alternative means to give permission!
id ---- pageID ----- userID ------ Permission
1 1 1 1
2 2 1 1
3 3 1 1
4 4 1 1
5 5 1 1
6 1 2 1
7 2 2 0
8 3 2 0
9 4 2 1
10 5 2 0
public class variables { public const int permissiontopageone = 1; public const int permissiontopagetwo = 2; public const int permisiontopagethree = 3; public const int permissiontopagefour = 4; public const int permissiontopagefive = 5; //.............Example Of Setup } public partial class PageOne:Page { private Verify _verify = new Verify(); protected void Page_Load(object sender, EventArgs e) { VerifyGrantedAccess(); if (!IsPostBack) { SetUp(); } } private void VerifyGrantedAccess() { _verify.ValidateAccess(Session[userID]); if (_verify.permissiontopageone == false) { //Denied Access Response.Write("You Do Not Have Access To This Page"); } } private void SetUp() { Response.Write("What would you like to do today? Please select from the drop down list"); } } public class Verify { private bool _permissiontopageone = false; private bool _permissiontopagetwo = false; private bool _permisiontopagethree = false; private bool _permissiontopagefour = false; private bool _permissiontopagefive = false; //Run SQL Query To Check If User Has Access .... 1 is yes, 0 is no public Verify ValidateAccess(int userID) { foreach (DataRow row in _dsTables[0].Rows) { case Variables.permissiontopageone: if(row[Permission] == 1) { _permissiontopageone = true; } else { _permissiontopageone = false; } case Variables.permissiontopagetwo: if(row[Permission] == 1) { _permissiontopagetwo = true; } else { _permissiontopagetwo = false; } //......And this continues for each page listed } } }