ASP.NET

Also checkout my blogs on: PMP | C# | SQL | Personal

 
  Monday, January 09, 2006

How to control access to specific pages based on authorization

At any point in the applicaiton, one can do the following...

IPrincipal usr = HttpContext.Current.User
If (usr.IsInRole("Admin") == false)
Response.Redirect("AccessDenied.aspx");
//usr.Identity.Name gives the logged in user id. If wanted
The above can be put in "Page_Load" event (or, OnLoad event) of the aspxs page to restrict control.

0 Comments:

Post a Comment

<< Home