Hello Experts,
I have a weird scenario occurring.
We have a piece of code in the Master Page that should check if a user is logged in or not.
- If a user IS NOT logged in, then some contents need to be displayed.
- If a user IS logged in, then no extra contents need to be displayed.
Here is the code:
template.master:
The Behavior:Code:<% if (!HttpContext.Current.User.Identity.IsAuthenticated) {%> <SOME CONTENT IS LOCATED HERE> <%}%>
This works correctly for all pages - when a user is logged in, the HTML disappears. When a user is NOT logged in the content is displayed.
The Problem:
When we navigate to createaccount.aspx, it stops working - it always thinks the user is indeed logged in even though the user has not logged in.
In order to fix the problem the user has to log in and log out and only then does the master page once again starts working.
What am I doing wrong?
Is that the correct way to check if a user is logged in?