More in this section

Forums / Developing with Sitefinity / Adapting the Redirect Function in the Login

Adapting the Redirect Function in the Login

2 posts, 0 answered
  1. Chris
    Chris avatar
    1 posts
    Registered:
    16 Sep 2008
    06 Jan 2009
    Link to this post
    I am building a membership portal for a subscription based service with 3 membership levels.  I am setting up a role for each membership level to manage the permissions to the pages inside the CMS.

    I need to modify the login process so each role has their own landing page once the user logs into the application.  Any ideas on how to accomodate that?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jan 2009
    Link to this post
    Hi Chris,

    Here is a simple example how to get users redirected to the pages where they have access, you could create a page under the group page and then specify where the users will  be redirected after login (Example: user1: ~/Group1/User1.aspx; user2: ~/Group1/User2.aspx).

    You need to check whether the user is anonymous and then redirect the user to your login form:

    if (!Page.User.Identity.IsAuthenticated) 
                Response.Redirect = ""
     
    After that using if conditions you could redirect the user to the appropriate page:

    if (strUserName == "John")  
        {  
       Response.Redirect("");  
        }  
    if (strUserName == "Bill")  
        {  
       Response.Redirect("");  
        }  

    or
    working with roles in the same way using Page.User.IsInRole which determines whether the current principal belongs to a given role.

    if (Page.User.IsInRole("Role1")  
            {  
                Response.Redirect("~/Group/User1.aspx");  
          .... 
      
     ....  
            }  

    There is a way to add some logic to the Login control after you have added
    handler for the LoggedIn event

       void Login1_LoggedIn(object sender, EventArgs e)   
        {   
            string userUrl = String.Format("~/account.aspx?user={0}"this.Login1.UserName);   
            this.Response.Redirect(this.ResolveUrl(userUrl), true);   
        }   

    I hope this helps.


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered