Copied to clipboard

Flag this post as spam?

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


  • David F. Hill 122 posts 242 karma points
    Jun 23, 2010 @ 22:22
    David F. Hill
    0

    ASP.Net membership provider in Umbraco

    Hello Umbraco Colleagues,
    I'm having difficulty with Membership and Login in Umbraco 4.0.4.1.
    I'm been trying to develop a custom login control for the ASP.Net membership provider in Umbraco without success.

    (Is this not the way to go - given that the Umbraco Member API is being obsoleted?)

    I have set up the Members, Member Groups, and Member Types using Umbraco's built-in functionality.

    Using this:

    FormsAuthentication.Authenticate(LoginNameTextBox.Text, passwordTextBox.Text)

    does not work. No authentication occurs.

    However, if I put a regular login control on the page (<asp:Login ID="Login1" runat="server"></asp:Login>), I'm able to log in successfully.
    I don't understand this and many other aspects of using the ASP.Net membership provider with Umbraco - and I've read everying I can find.

    For many reasons, I don't want to use the out-of-the-box login control. I'd like to build my own.

    Any help is greatly appreciated. Thanks!

    David Hill

    PS - Hope you're all enjoying Codegarden 2010!!!

  • Paul Blair 466 posts 731 karma points
    Jun 23, 2010 @ 23:49
    Paul Blair
    0

    David,

    If the reason you want to write your own control is because of the markup supplied by the login control you can add the control to a user control/web form and then in design mode go to the control tasks and choose "convert to template".

    All your code needs to work is to have textbox's labeled the same e.g. <asp:TextBox ID="UserName" runat="server"></asp:TextBox>.

    As an example here is a control I have created:

            <asp:Login ID="Login1" runat="server" FailureText="Your email or password was incorrect. Please try again."
                Width="100%" PasswordRecoveryText="Forgot your password." PasswordRecoveryUrl="~/Registration.aspx"
                CreateUserText="Register" CreateUserUrl="~/Registration.aspx">
                <LayoutTemplate>
                    <div id="memberControls">
                        <div class="row">
                            <div class="memberLabel"><label >Email: <span>*</span></label></div>
                            <asp:TextBox ID="UserName" runat="server" CssClass="txtinput"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="ctl00$Login1">*</asp:RequiredFieldValidator>
                        </div>
                        <div class="row">
                            <div class="memberLabel"><label >Password: <span>*</span></label></div>
                            <asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass="txtinput" ></asp:TextBox>
                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ctl00$Login1">*</asp:RequiredFieldValidator>
                        </div>
                        <div id="errorrow">
                            <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                        </div>
                        <div class="row">
                            <asp:CheckBox ID="RememberMe" runat="server" CssClass="chkBox" />
                            <div class="memberLabel" style="width:40%">
                                <label>Remember me</label>
                            </div>
                            <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" CssClass="button"
                                ValidationGroup="ctl00$Login1" />
                        </div>
                        <div class="row">
                        </div>
                        <div class="row">
                            <br />
                            <asp:HyperLink ID="btnNotRegistered" runat="server" Text="Not Registered Yet?" /><br />
                            <asp:HyperLink ID="btnForgotPassword" runat="server" Text="Forgot Password?" />
                        </div>
                    </div>
                </LayoutTemplate>
            </asp:Login>

    I also suggest looking at the http://our.umbraco.org/projects/osmembercontrols/ package - either to sue or for ideas.

    Cheers

    Paul

  • David F. Hill 122 posts 242 karma points
    Jun 24, 2010 @ 20:21
    David F. Hill
    0

    Thanks, Paul.

    I guess I'll have to use the ASP.Net login control if I want to use the ASP.NET Membership Provider model.

    David

  • Nuno Costa 1 post 21 karma points
    Jun 24, 2010 @ 21:39
    Nuno Costa
    0

    This is the line of code you will have to use :

    Member.AddMemberToCache(currentMember);

  • Anders Brännmark 228 posts 280 karma points
    Jun 27, 2010 @ 10:54
    Anders Brännmark
    0
      Membership.ValidateUser(strUsername, strPassword); 

    Returns true if username and password matches.

    Login timeout is set in web.config

     

Please Sign in or register to post replies

Write your reply to:

Draft