Geeks With Blogs
mikedopp Geekswithblogs (edition)

I have been looking for a better way to handle redirects but this works very well.

 1: <%@ Page Language="C#" %>
 2: <%@ Import Namespace="System.Security" %>
 3: <script runat="server">
 4:  
 5:  void Page_Load()
 6:  {
 7:  if(Roles.IsUserInRole("Admin"))
 8:  {
 9:  Response.Redirect("~/members/admin/default.aspx");
 10:  }
 11:  else if (Roles.IsUserInRole("Member"))
 12:  {
 13:  Response.Redirect("~/members/users/default.aspx");
 14:  }
 15:  else
 16:  {
 17:  Response.Redirect("~/default.aspx");
 18:  }
 19:  }
 20:  
 21: </script> 

If you want to display an access denied page just change the default.aspx to:

 1:  Else
 2: Response.Redirect ("~/AccessDenied.aspx")
Enjoy!!! Posted on Friday, September 21, 2007 2:57 PM | Back to top


Comments on this post: Redirect Roles to specific pages

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © mikedopp | Powered by: GeeksWithBlogs.net