T
trullock
Hi,
I need to control access to certain pages in my site, via the use of
forms based authentication and roles.
Now i've got the pages i want protected by a login form and thats all
working great. However, I need to implement an "access level" system
where once logged in, you can only access certain pages depending on
the roles you have assigned to you.
For example, user Joe can access page A, B and C, but user Bob can
only access page B.
At the moment im controlling this by only showing the respective links
on my navigation menu, by doing:
link.visible = user.isinrole("Level 2")
However, you could still access the page by typing in the url.... So
ive put this at the top of my class definition for each page:
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = "Level
2")]
But when an unauthorized user accesses the page i get a security
exception
How do i handle this exception? Am i going about this whole thing the
right way?
Thanks for any advice
Andrew
I need to control access to certain pages in my site, via the use of
forms based authentication and roles.
Now i've got the pages i want protected by a login form and thats all
working great. However, I need to implement an "access level" system
where once logged in, you can only access certain pages depending on
the roles you have assigned to you.
For example, user Joe can access page A, B and C, but user Bob can
only access page B.
At the moment im controlling this by only showing the respective links
on my navigation menu, by doing:
link.visible = user.isinrole("Level 2")
However, you could still access the page by typing in the url.... So
ive put this at the top of my class definition for each page:
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = "Level
2")]
But when an unauthorized user accesses the page i get a security
exception
How do i handle this exception? Am i going about this whole thing the
right way?
Thanks for any advice
Andrew