More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Sunday, 12 April 2009 4:14:21 AM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 23/11/2008(UTC)
Posts: 519

ASP.net 2.0 login control with membership(Access) and roles is very easy to use. You can set up users and passwords (authentication), create roles (groups of users), and create permissions (rules for controlling access to parts of your application or folders).

To redirect user according to their roles, use logged in event of the login control Login1:
protected void Login1_LoggedIn(object sender, EventArgs e)
{
if (Roles.IsUserInRole(Login1.UserName, "Admin"))
{
Login1.DestinationPageUrl = "~/Secure/Admin/Admin.aspx";
}
else if (Roles.IsUserInRole(Login1.UserName, "Member"))
{
Login1.DestinationPageUrl = "~/Secure/Member/Member.aspx";
}
...

if (Login1.DestinationPageUrl != "")
{
Response.Redirect(Login1.DestinationPageUrl);
}
}

Note:
1. use Roles.IsUserInRole() instead of User.IsInRole();
2. just specifying Login1.DestinationPageUrl is not guaranteed correct redirection. It may redirect to the defaulturl. So Response.Redirect() is needed.
Sponsor
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.