More in this section

Forums / Developing with Sitefinity / How to redirect user ?

How to redirect user ?

2 posts, 0 answered
  1. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    16 Mar 2009
    Link to this post

    How to redirect user, for example, which in role Publishers to other page ~/Publishers/Publishers.aspx. I try add this code in ~\Sitefinity\Login.aspx.cs :

     void Login1_LoggedIn(object sender, EventArgs e)

    {

    ...................

    if (UserManager.Default.IsUserInRole(this.Login1.UserName,"Publishers"))
    {
    this.Page.Response.Redirect("~/Publishers/Publishers.aspx", true);

     }

    this.Page.Response.Redirect(redirectUrl, true);

    }

    But it does not work. What I did wrong?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    16 Mar 2009
    Link to this post
    Hi rent,

    Give a try to the sample below:

    string loggedInUser = ((TextBox) Login1.FindControl("UserName")).Text; 
    UserManager man = new UserManager(); 
    string ad = "administrators"
    if(man.IsUserInRole(loggedInUser, ad)) 
     { 
        Response.Redirect("http://www.yahoo.com"); 
     } 

    I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered