Wednesday, 9 March 2011

Redirect users on login according to membership roles

If you wish to send membership users to different locations according to their role, then intervene at the LoggedIn event on your login page like so:

protected void Login1_LoggedIn(object sender, EventArgs e)
if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
  // User.IsInRole won't work here here
  if (Roles.IsUserInRole(LoginUser.UserName, "SysAdmin"))
  else if (Roles.IsUserInRole(LoginUser.UserName, "Owner"))

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!