Context.User.IsAuthenticated = false?????

J

James Coleman

I have a asp:Login control with an OnLoggedIn="Login1_LoggedIn" method.

The first time through the method the Context.User.IsAuthenticated = false.
The 2nd time I log in, it is then true. Anyone know why this is, am I doing
something wrong, is there a way around it?

protected void Login1_LoggedIn(object sender, EventArgs e)
{
Login myLogin = sender as Login;

// if we get a Ticket from AuthenticateAsUser the credentials are
valid
//Ticket =
CmsFormsAuthentication.AuthenticateAsUser(Login1.UserName, Login1.Password);
if (Context.User.IsInRole("Admin"))
{
//Ticket =
CmsFormsAuthentication.AuthenticateAsUser("WinNT://webacom/jcoleman",
"`1q`1q");
Ticket = CmsFormsAuthentication.AuthenticateAsUser("WinNT://" +
WebConfigurationManager.AppSettings["ADMIN_USERNAME"],
WebConfigurationManager.AppSettings["ADMIN_PASSWORD"]);
}
else if (Context.User.IsInRole("Dealer"))
{
Ticket = CmsFormsAuthentication.AuthenticateAsUser("WinNT://" +
WebConfigurationManager.AppSettings["DEALER_USERNAME"],
WebConfigurationManager.AppSettings["DEALER_PASSWORD"]);
}
else
{
CmsFormsAuthentication.AuthenticateAsGuest();
}
if (Ticket != null)
{
CmsFormsAuthentication.SetAuthCookie(Ticket, false,
Login1.RememberMeSet);
}
}

Thanks
~James
 
D

Dominick Baier [DevelopMentor]

to be "authenticated" you need an extra roundtrip to the client to set the
authentication ticket.

thats why you see this behavior.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top