Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig O'Mahony 364 posts 918 karma points
    Nov 08, 2012 @ 14:37
    Craig O'Mahony
    0

    Set members landing page

    Hi I'm using the standard asp.net login control to allow members to log into my site and all is well with that side of things. What i want to be able to do is send the logged in user to a members landing page after they have successfully signed in and I don't know how to acheive this. Is this possible at all?

    Thanks,

    Craig

  • Thomas 66 posts 88 karma points
    Nov 08, 2012 @ 15:56
    Thomas
    0

    Hi Craig

    Yes, it is possible, if you create a macro, that sends the user to the the desired landing page (add a content picker to the member properties and you should have the id). Insert the macro on the current landing page, and if set redirect the user to that page. You can also let the user decide which page by setting the node Id using the API. Hope this helps.

    bool isLoggedIn HttpContext.Current.User.Identity.IsAuthenticated;
      if (isLoggedIn)
        var currentUser Membership.GetUser();
        var currentMemberID currentUser.ProviderUserKey.ToString();
        Member member;
        member new Member(currentMemberID.AsInt());
        if (member.getProperty("landingpage").Value!=0){
          Response.Redirect(@Library.NodeById(member.getProperty("landingpage").Value).Url);
        }
      }  

  • Craig O'Mahony 364 posts 918 karma points
    Nov 08, 2012 @ 16:52
    Craig O'Mahony
    0

    Hi Thomas,

    Thanks for this, not sure that I fully understand though (!), currently when a user logs in they get bounced to the home page. If I assign a macro on the home page won't the user get bounced to the landing page every time they try to view the home page? The home page needs to still be available for the browser?

    Thanks again,

    Craig

  • Thomas 66 posts 88 karma points
    Nov 08, 2012 @ 17:05
    Thomas
    0

    Yes, that's right.

    You could bounce the user to a redirecting default landing page instead, and then redirect them to the homepage, if no other landing page has been set.

    Or even better include the redirect in a razor-based login macro (like https://gist.github.com/874194 ) where requestedUrl is substituted with the memberspecific landing page.

  • Craig O'Mahony 364 posts 918 karma points
    Nov 09, 2012 @ 09:57
    Craig O'Mahony
    0

    Hi Thomas,

    That chunk of razor code is exactly what I needed. You are a star (as in most of this community! :)

    Thanks,

    Craig

  • Thomas 66 posts 88 karma points
    Nov 09, 2012 @ 10:38
    Thomas
    0

    You are more than welcome, I'm glad I could help. 

Please Sign in or register to post replies

Write your reply to:

Draft