When users log in, their sessions are set like so:
HttpContext.Current.Session["LoggedIn"] = true;
HttpContext.Current.Session["FullName"] = (string)Reader["FirstName"] + " " + (string)Reader["LastName"];
My Site.master file contains a navigation menu that’s site-wide, and I’d like to change it to show different links depending on if the user is logged in or not.
Something like this in Site.master:
<div id="navigation">
<ul>
<%
if (HttpContext.Current.Session["LoggedIn"] != null)
{
%><li><a href="/user74/aspnet/Logout.aspx">Log out</a></li><%
}
else
{
%>
<li><a href="/user74/aspnet/Register.aspx">Register</a></li>
<li><a href="/user74/aspnet/Login.aspx">Log in</a></li>
<%
}
%>
</ul>
</div>
However, this doesn’t seem to work. Looks like you can’t use ASP tags like PHP tags.
How can I achieve this?
Seems like you are more in to PHP,For starters I recommend you go for the normal .NET process
1.Write HTML in aspx page,replace HTML ‘a’ with asp:linkbutton ,likr
2.Write codes in pagename.aspx.cs page,in your case write session checks in page_load event