Thread: Login Macro
View Single Post
  #1 (permalink)  
Old August 28th, 2013, 02:24 PM
scorpio26krf scorpio26krf is offline
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Login Macro

Hi All -

You can find the Login Macro on Page 244 - 246.

I have a client using Umbraco 4.7.1. They requested a login page for board members. I followed the book: made the required web.config change (DefaultMemberTypeAlias attribute match one of my configured Member types). Then I created the login.ascx page, copied the code from the book on the front end and code behind pages(see below). I compiled, went into Umbraco and created the login Macro, told it to use the .NET User Control Login.ascx. Then I added that Macro to a page. Added a protected page, told the protected page to go to the page with the login macro as a login page. It goes to the correct page, and I can see the control fine. However, nothing happens when I click 'login'. I have a user created. Any guidance would be helpful.

Login.ascx
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Login.ascx.cs" Inherits="LifeSkills.usercontrols.Login" %>
<asp:Login ID="_loginForm" runat="server">
</asp:Login>
Login.ascx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LifeSkills.usercontrols
{
    public partial class Login : System.Web.UI.UserControl
    {
        //The default redirect page after loggin in
        public int LoginRedirectPage { get; set; }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _loginForm.LoggedIn += LoginUser_LoggedIn;
        }

        //When the user has successfully authenticated redirect to the specified page
        void LoginUser_LoggedIn(object sender, EventArgs e)
        {
            Response.Redirect(umbraco.library.NiceUrl(LoginRedirectPage));
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}
Reply With Quote