User Redirect to Individual Pages

Last post 07-04-2007 1:20 AM by zakman411. 3 replies.

Sort Posts:

  • User Redirect to Individual Pages

    07-03-2007, 7:11 PM
    • Loading...
    • zakman411
    • Joined on 06-21-2007, 9:23 PM
    • California
    • Posts 52

     Hey All,

    I'm currently using a modified club starter kit and im trying to figure out the easiest and most secure way to redirect users to their own personal page when they login. i already have the login names and pages set up, and i can create a link to them no problem, but i need to redirect the users when they are authenticated. i have placed the user pages into a folder, such as:

    ~/users/john/welcome.aspx

    I did this because i wanted to be able to put files into the users (john) page. That way, it would be protected (i have protected the ~/john/ folder so it can only be accessed by john and admin)

    What would be the easiest way to redirect users when they are authenticated? 

     

    -------

    I took a look at the club starter kit and their is a page just for redirect. Here is the code:

    <script runat="server">
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            If Page.User.Identity.IsAuthenticated Then
                Response.Redirect("Member_Details.aspx")
            Else
                Response.Redirect("Member_register.aspx")
            End If
        End Sub
    </script>

    Could i modify this to work with users instead?

     

    Thanks in Advance
     

    -Zach Spitulski-
  • Re: User Redirect to Individual Pages

    07-03-2007, 9:43 PM

    if u are using>>> forms authentication>>>

    the u can use

    FormsAuthentication.RediectFromLoginPage(authenticatedUser.UserName ,false)

    or in your example code use>>

     

      If Page.User.Identity.IsAuthenticated Then
    Response.Redirect("Member_Details.aspx?uid=" + System.Web.HttpUtility.UrlEncode(Page.User.Identity.Name));

     

    and use this query string(uid) in userinfo page......

     

    mark post as answer if it helped you

    Have a Great Day!

  • Re: User Redirect to Individual Pages

    07-03-2007, 9:48 PM
    Answer
    • Loading...
    • worldspawn[]
    • Joined on 01-19-2003, 6:21 PM
    • Melbourne, Australia
    • Posts 637

    Hi Zack,

    r u planning on having individual folders for each user? Sounds... nasty :)

    Can't you have a dynamic page that serves content unique to the user.. dynamically... based on their authentication information? Also there are alternatives to controlling access using directory paths.

    That aside, you can redirect the user with a good ol' fashioned Response.Redirect at the end of your authentication code (or wherever u'd like). I have at this point assumed ur using forms authentication, let me know if this is wrong. I don't know anything about the club starter kit. If the user's folder name is the same as their username then the following should work:
    Response.Redirect(string.Format("~/users/{0}/welcome.aspx", Context.User.Identity.Name))

    -- Sam Critchley

    "Wise man say 'forgiveness is divine, but never pay full price for late pizza." - TMNT

    shivam.com.au
  • Re: User Redirect to Individual Pages

    07-04-2007, 1:20 AM
    • Loading...
    • zakman411
    • Joined on 06-21-2007, 9:23 PM
    • California
    • Posts 52

    thanks to both of you for your answers! 

    Ok, i got it! I inserted that line of code as a script into my default page, and it redirected users, unless they werent logged in. Looked like this:

     

    <script runat="server">
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            If Page.User.Identity.IsAuthenticated Then
                Response.Redirect(String.Format("~/users/{0}/welcome.aspx", Context.User.Identity.Name))
            Else
            End If
        End Sub
    </script>

    Works Great! Thanks Guys 

    -Zach Spitulski-
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter