Click here to Skip to main content
15,909,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have FormsAuthentication in place like this in web.config file:

XML
<authentication mode="Forms">
    <forms name="Login" loginUrl="/WebPages/Default.aspx?Action=Login"
        defaultUrl="/WebPages/Default.aspx?Action=Login"
        protection="All" path="/WebPages/" />
</authentication>
<authorization>allow users="?" </authorization>



I have a LoginStatus control in the mainpage, which shows 'Login' to startwith. When I click on that, it will redirect me to the login page. After logging in successfully, I go back to the main page. But the LoginText of LoginStatus control is not updated..i.e., it still shows 'Login'. When I click on the LoginStatus again for the second time, then it is updated to 'Logout' and I go to the Login page.
The LoginStatus control is defined like this:

<asp:loginstatus id="LoginStatus1" runat="server" logoutaction="Redirect" logoutpageurl="~/WebPages/Default.aspx" xmlns:asp="#unknown" />


What should I do to get the LoginStatus to show correct text first time itself??
Posted
Updated 13-Sep-10 13:02pm
v2

Did you use LoginView ?

XML
<asp:LoginView ID="LoginView1" runat="Server">
    <AnonymousTemplate>
        <span style="font-family: Arial; font-size: 10pt;">Welcome, Guest
            <asp:LoginStatus ID="LoginStatus1" runat="Server" />
        </span>
    </AnonymousTemplate>
    <LoggedInTemplate>
        Welcome,
        <asp:LoginName ID="LoginName1" runat="Server" />
        <asp:LoginStatus ID="LoginStatus1" runat="Server" />
    </LoggedInTemplate>



The LoggedInTemplate should have LoginStatus in it.


Also have a look into this.
http://www.developer.com/net/asp/article.php/3655706/ASPNET-Tip-Using-the-LoginName-and-LoginStatus-Controls.htm[^]
 
Share this answer
 
Hi Abhishek,
Thanks for the reply. I tried your sample but no luck. I guess there is something to do with the Login control, which is like this:

XML
<asp:Login ID="LoginAdmin" runat="server" BackColor="White"
                    BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px"
                        EnableTheming="True" EnableViewState="True"
                        Font-Names="Verdana" Font-Size="10pt"
                        TitleText="Admin Log In" Font-Bold="False"
                        Width="340px" DestinationPageUrl="~/WebPages/Welcome.aspx"
                        onloggedin="LoginAdmin_LoggedIn" VisibleWhenLoggedIn="False">
                    <LoginButtonStyle Font-Bold="False" Font-Names="Verdana" Font-Size="Small" />
                        <LayoutTemplate>
                            <table border="0" cellpadding="1" cellspacing="0"
                                style="border-collapse:collapse;">
                                <tr>
                                    <td>
                                        <table border="0" cellpadding="0" style="width:530px;">
                                            <tr>
                                                <td align="center" colspan="2"
                                                    style="color:White;background-color:#6B696B;font-weight:bold;">
                                                    Admin Log In</td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-weight:normal;" class="style1">
                                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User
                                                    Name:</asp:Label>
                                                </td>
                                                <td align="left">
                                                    <asp:TextBox ID="UserName" runat="server" Width="170px"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
                                                        ControlToValidate="UserName" ErrorMessage="User Name is required."
                                                        ToolTip="User Name is required." ValidationGroup="LoginAdmin">*</asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-weight:normal;" class="style1">
                                                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                                                </td>
                                                <td align="left">
                                                    <asp:TextBox ID="Password" runat="server" TextMode="Password" Width="170px"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
                                                        ControlToValidate="Password" ErrorMessage="Password is required."
                                                        ToolTip="Password is required." ValidationGroup="LoginAdmin">*</asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="center" colspan="2" style="color:Red;">
                                                    <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="center" colspan="2">
                                                    <asp:Button ID="LoginButton" runat="server" CommandName="Login"
                                                        Font-Bold="False" Font-Names="Verdana" Font-Size="Small" Text="Log In"
                                                        ValidationGroup="LoginAdmin" onclick="LoginButton_Click" />
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <LabelStyle Font-Bold="False" />
                    <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
                </asp:Login>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900