I have a web application on VS2005 C# and I would want to check if user is logged in the application.
Currently I am trying
if (LoginName.Equals(null))
{
Response.Redirect("/Project/Login.aspx");
}
but I seem to be getting some errors.
Anyone can tell me how I should do it or is there any better ways too check?
Thank you
EDIT:
Sorry for being unclear with my question.
LoginName is the System.Web.UI.WebControls.LoginName.
The error I am getting is `An object reference is required for the nonstatic field , method or property ‘object.Equals(object)’
Your actual question seems to be How can i check if a user is authenticated? You should edit the title of your question.
When using an ASP.NET authenticationprovider you can check if a user is authenticated with this code in your code behind files:
You can access the username for example with