Solved

Login Control Issue

Posted on 2010-09-16
10
508 Views
Last Modified: 2012-05-10
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
Comment
Question by:ktola
  • 5
  • 5
10 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 33693739
-->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
 

Author Comment

by:ktola
ID: 33693759
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 33693965
Just wondering if you have settings to clear history upon browser closing and that is wiping out the cookie?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ktola
ID: 33694087
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 33694205
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
 

Author Comment

by:ktola
ID: 33694237
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
 
LVL 41

Expert Comment

by:guru_sami
ID: 33694443
-->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
 

Author Comment

by:ktola
ID: 33694465
That is correct - but I already wiped out the Registry settings and it made no difference
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 33694712
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
 

Author Closing Comment

by:ktola
ID: 33753682
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question