I would like to create a custom login page for my website and have to integrate with Umbraco.I would like to check a session value in master page and if there is no value available it will redirect to the login page and set the session there, otherwise it will display the home page of my website.
Hi. Why for to invent a wheel? ASP.NET has a built-in mechanism for authentication. You just need to set it up properly and to turn to use a standard asp.net login control.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Set the page where to go after a user logged on.
dynamic currentNode = new DynamicNode(Node.GetCurrent());
LoginMember.DestinationPageUrl = library.NiceUrl(currentNode.sportLink);
}
}
If you want that your login page would be a default one you just move it to the top of the content tree. In such a case you will also have to set defaultRedirect settings in the web.config file (<system.web>/<authentication>/<forms> section) to the start url of your site (like defaultRedirect="/home/"), so that to avoid redirecting back to the login page itself after logging in.
I've never changed anything in web.config for a login system in Umbraco. You can set rights on nodes and there you can specify a login page if the user tries to visit that page while he is not logged in. By setting LoginMember.DestinationPageUrl you can specify to what page the user should go after he's logged in.
But why would you want to set it in the web.config? By using LoginMember.DestinationPageUrl in the code you can use a node from umbraco which is selected with a content picker. That's more flexible and it can be changed in Umbraco by a user who has no rights to the web.config.
Yeah, I understand, but old habits die hard :-) Of course when it comes to umbraco setting it through the property has lots benefits since it always allows to change its value through the backoffice.
Custom Login
Hi,
I would like to create a custom login page for my website and have to integrate with Umbraco.I would like to check a session value in master page and if there is no value available it will redirect to the login page and set the session there, otherwise it will display the home page of my website.
Please help me ASAP.
Regards
Anju
Hi. Why for to invent a wheel? ASP.NET has a built-in mechanism for authentication. You just need to set it up properly and to turn to use a standard asp.net login control.
Here is an example of a custom login control. It's fully customizable.
.aspx
.cs
Jeroen
Thanks Jeroen.
How we set this page as default page inside umbraco?
If you want that your login page would be a default one you just move it to the top of the content tree. In such a case you will also have to set defaultRedirect settings in the web.config file (<system.web>/<authentication>/<forms> section) to the start url of your site (like defaultRedirect="/home/"), so that to avoid redirecting back to the login page itself after logging in.
You can add this usercontrol in a macro and place that on a template. Create a special login node and give it this template. You can watch a free video on how to do this here: http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/developer-introduction/using-net-user-controls/TVPlayer.
I've never changed anything in web.config for a login system in Umbraco. You can set rights on nodes and there you can specify a login page if the user tries to visit that page while he is not logged in. By setting LoginMember.DestinationPageUrl you can specify to what page the user should go after he's logged in.
Jeroen
"By setting LoginMember.DestinationPageUrl you can specify to what page the user should go after he's logged in."
Actually it's the same - if DestinationPageUrl is not set in the Login control then this control fallbacks to the defaultUrl from web.config.
But why would you want to set it in the web.config? By using LoginMember.DestinationPageUrl in the code you can use a node from umbraco which is selected with a content picker. That's more flexible and it can be changed in Umbraco by a user who has no rights to the web.config.
Jeroen
Yeah, I understand, but old habits die hard :-) Of course when it comes to umbraco setting it through the property has lots benefits since it always allows to change its value through the backoffice.
is working on a reply...