Link to home
Create AccountLog in
Avatar of Anand Majmundar
Anand MajmundarFlag for India

asked on

How to hide or Show a view based on logged in Status in .NET 4.5 asp.net Web Application.

Backdrop: Have a working .NET 3.5 website project NetConnectX. To the same solution added a .NET 4.5 Web Application WebApplication1. Copied relevant files fro NetConnectX to WebApplication1 and introduced code for External Google Authentication.  Deleted NetConnectX Project in the Solution. WebApplication1 compiles well and executes except that it does not show Logged In View on a successful Login. Logged In View  for NetConnectX backup solo project in solution continues to work fine.  Have not attempted Google Authentication Button Click yet.  The issue being discussed is for manual Login.


The aspx code for Manual Login:


    <p align="left"><asp:LoginStatus ID="LoginStatus1" runat="server" align="center" Font-Names="Helvetica" ForeColor="Green" Font-Size="17px" Font-Bold= "True" style="text-decoration:none"

        LoginText="Guest Sign In" LogoutText="Sign Out" /></p>

 <p align="left">

    <asp:LoginView ID="LoginView1" runat="server">

        <LoggedInTemplate>

            <span class="Apple-style-span" 

                style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: small; ">

            <span class="Apple-style-span" 

                style="font-family: 'Arial'; font-size: 13px; text-align: left; Color:#D2691E; ">

            <b style="font-family: Arial; font-size: Small; text-align: left; Color:"Green";">Welcome, </b><asp:LoginName 

                ID="LoginName1" runat="server" Font-Names="Helvetica" ForeColor="Green" />

            </span></span>

            <br />

            <br />

            <asp:HyperLink ID="HyperLink3" runat="server"  Font-Names="Helvetica"  ForeColor="#D2691E"  font-size=12px  style="text-decoration:none"

                NavigateUrl="~/gridNOW_ChangePassword.aspx">Change Password (Members Only)</asp:HyperLink>

            <br />      

            <br />      

        </LoggedInTemplate>


        <AnonymousTemplate>

            <span class="Apple-style-span" 

                style="font-family: Arial; font-size: 16px; text-align: left; Color:#D2691E;">

            <span class="Apple-style-span" 

                style="font-family: 'Segoe UI', Verdana, Tahoma; font-size: 16px; text-align: left; ">

            <b style="font-family: Tahoma; font-size: 17px; text-align: left; Color:#D2691E;">Almost Done. <span class="guest">Guest SignIn</span> needs No SignUp.</b></span></span>

             <br />            

            <br />

            <asp:HyperLink ID="HyperLink4" runat="server" Font-Names="Helvetica"  ForeColor="Green"  font-size=small  style="text-decoration:none"

                NavigateUrl="~/gridNOW_Register.aspx">Member Sign Up (By Invitation Only)</asp:HyperLink>


            <br />       

            <br  class="style2"/>

            <span class="style2">

            <asp:HyperLink ID="HyperLink5" runat="server" Font-Names="Helvetica"  ForeColor="#D2691E"  font-size=small  style="text-decoration:none"

                NavigateUrl="~/gridNOW_RecoverPassword.aspx">Recover Password (Members Only)</asp:HyperLink>

            </span>   

        </AnonymousTemplate>

    </asp:LoginView></p>

Avatar of Anand Majmundar
Anand Majmundar
Flag of India image

ASKER

My Google External Authentication OAuth Code:

https://csharp-video-tutorials.blogspot.com/2016/12/aspnet-web-api-google-authentication.html

Although, this code does not appear to have any implication on Manual Login LoggedInView visibility issue that is being faced.
Have migrated from .NET 3.5 Website to .NET 4.5 Web Application. Is that the reason why Logged in View is disabled?

Is it mandatory to implement the code on the lines of the link below in a Web Application?


https://csharp-video-tutorials.blogspot.com/2019/06/show-or-hide-login-and-logout-links.html
ASKER CERTIFIED SOLUTION
Avatar of Anand Majmundar
Anand Majmundar
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account