Add this to the top of your Login macro partial, of just the same template as the login form:
var anotherPageId = 1222;
var loginStatusModel = Members.GetCurrentLoginStatus();
if (loginStatusModel.IsLoggedIn)
{
Response.Redirect(new DynamicNode(anotherPageId).Url);
}
But you should probobly fetch the "anotherPageId" dynamicly and not hardcode it like i did, but this is just an example.
I dont know actually, i just copied this code snippet from an old project i built a while back. Im not sure if RedirectToUmbracoPage works in the header or if it only works in a controller.
Try and see, but the code in the previous post does the same thing. And you know what they say: "If it ain´t broke..." :)
Redirect to another page when Member is curently logged in and tries to access the login page
Hi,
I have a document type called Login which is a page that contains a login form for our members.
What I am trying to do is, when a member that is already logged in and access the login page he gets redirected to another page.
How can I accomplish this?
/Michael
Add this to the top of your Login macro partial, of just the same template as the login form:
But you should probobly fetch the "anotherPageId" dynamicly and not hardcode it like i did, but this is just an example.
Hi Dennis,
thanks for the reply.
Can't you use the
RedirectToUmbracoPage
?/Michael
I dont know actually, i just copied this code snippet from an old project i built a while back. Im not sure if
RedirectToUmbracoPage
works in the header or if it only works in a controller.Try and see, but the code in the previous post does the same thing. And you know what they say: "If it ain´t broke..." :)
Hi Dennis,
I used your code but I get the following exception:
{"Server cannot append header after HTTP headers have been sent."}
I have tried placed your code on top of the view and by creating a custom controller for the login document type but both give me the same result.
What am I missing here??
/Michael
Strange, works for me. Can you show your code?
Here is the code using razor in my login.cshtml view page:
Try this:
Otherwise, try: http://stackoverflow.com/questions/159523/why-do-i-get-cannot-redirect-after-http-headers-have-been-sent-when-i-call-res
Dennis,
using this it works.
Thanks!
/Michael
Awsome, great to hear that is worked out for you! :)
Have a great weekend!!
Make Umbraco do less un-needy traversing of the tree :-)
Thanks for the headsup!
/Michael
You might want to check if myProsecPage is not null as well...
This snippet will check if its null, and if it is, we'll redirect to the homepage instead...
is working on a reply...