• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

Login Control Issue

I am using a custom template - shown in the code sample below - to host a Login control for an ASP.NET website.  If the Remember Me Next Time box is checked, I wanted the Username and Password fields pre-populated the next time a user comes to this page but that does not work.  

Not only does that not work, but the Password Manager in all browsers does not recognize these fields as a from and thus none of them offer to remember the password for me.  You cannot click on the textbox to get old usernames, etc...

I did verify that a cookie is being created upon login but it is not being utilized the next time through.

My web.config file already contains a machine key and uses the following froms entry:

<forms defaultUrl="Secure/Home.aspx" loginUrl="~/Login.aspx" name=".ASPXAUTH" path="/" protection="All" timeout="500000" slidingExpiration="true"/>

Can somebody please help me figure out what I am doing incorrectly?
<asp:Login ID="Login1" runat="server" RememberMeSet="True" Width="100%" OnLoggedIn="Login1_LoggedIn"
        OnLoginError="Login1_LoginError" ViewStateMode="Enabled" EnableViewState="true" onloggingin="Login1_LoggingIn">
        <LayoutTemplate>
            <asp:Literal ID="litFinishIt" runat="server" />
            <table border="0" cellpadding="0">
                <tr>
                    <td colspan="2">
                        <h2>
                            Welcome Users!</h2>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Literal ID="litSpecial" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" CssClass="formLabel">Email Address:</asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="UserName" CssClass="textBoxClass" runat="server" TabIndex="0"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                            ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" CssClass="formLabel">Password:</asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="Password" CssClass="textBoxClass" runat="server" TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." TabIndex="2" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        <asp:ImageButton ID="LoginButton" runat="server" ImageUrl="images/button_login1.gif"
                            Width="102" Height="31" CommandName="Login" AlternateText="Log In" ValidationGroup="Login1" /><br />
                        <br />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a href="PasswordRecovery.html">Forgot Your Password?</a>
                    </td>
                </tr>
            </table>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                ValidationGroup="Login1" ShowSummary="False" />
        </LayoutTemplate>
    </asp:Login>

Open in new window

0
ktola
Asked:
ktola
  • 5
  • 5
1 Solution
 
guru_samiCommented:
-->If the Remember Me Next Time box is checked, I wanted the Username and Password fields pre-populated the next time a user comes to this page but that does not work.  

Not, that is not the purpose of Remember Me. It's purpose is to automatically login based on the cookie. It does not keep your username/password.

To do that you will have to manually create a separate cookie to store those values. Then when they come to Login page, grab those values and populate the textboxes.
To get the username and password textboxes in code-behind, you will have to do findControl i.e Login1.FindControl("UserName").

Note: It is not a good idea to store passwords in cookie. You might want to consider all security aspects before going this route.
0
 
ktolaAuthor Commented:
Fair enough but the auto-login feature does not work either and why are none of the browsers recognizing this form as a form?
0
 
guru_samiCommented:
Just wondering if you have settings to clear history upon browser closing and that is wiping out the cookie?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
ktolaAuthor Commented:
That browsers automatically remember usernames and password for other sites - just not this one for some reason I do not understand.
Also, if you use IE, you know that using the same textbox name on different sites will enable IE to prepopulate that textbox with options.  You click on the textbox and those options appear.  That also does not work here and I have no idea why...
0
 
guru_samiCommented:
I doubt if it is because TextBoxes are inside of Login Control but for test purpose, can you place a Textbox on the same page as Login control and see if that is remembering the value to prepopulate.
0
 
ktolaAuthor Commented:
I actually created a page with just a standard Login control - no template, no fancy anything - and that does not work either.
I have other sites I have built with a standard Login control that have never had this issue
0
 
guru_samiCommented:
-->I actually created a page with just a standard Login control - no template, no fancy anything - and that does not work either.

I see...I tried just now placing a login control on a page and it worked in IE8 and FF.

Is your browser remembering everything from other sites and just not this one guy?



0
 
ktolaAuthor Commented:
That is correct - but I already wiped out the Registry settings and it made no difference
0
 
guru_samiCommented:
Check if the explanation provided here by hans_v on - how Remember Me works - helps:
http://forums.asp.net/p/999452/1314477.aspx#1314477

For the browser not remembering form data just for this one application....I have no idea.
0
 
ktolaAuthor Commented:
THank you for the link to getting Remember Me Next Time to work.  It still did not help with the current website but it provided some useful insights nonetheless.  I am not sure what is going on but it is clear that it is my code and not a shortcoming of the Login control...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now