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?
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); } }
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?
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.
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
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);
}
}
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
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.
Hi Thomas,
That chunk of razor code is exactly what I needed. You are a star (as in most of this community! :)
Thanks,
Craig
You are more than welcome, I'm glad I could help.
is working on a reply...