I am using form authentication with below method in my ASP.NET application
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, true);
How do I check whether user is logged in or not? And how can I get the user name of a logged in user?
This question is related to
c#
asp.net
forms-authentication
if (User.Identity.IsAuthenticated)
{
Page.Title = "Home page for " + User.Identity.Name;
}
else
{
Page.Title = "Home page for guest user.";
}
The simplest way:
if (Request.IsAuthenticated) ...
Easiest way to check if they are authenticated is Request.User.IsAuthenticated
I think (from memory)
Source: Stackoverflow.com