login loginedIn User.Identity.IsAuthenticated

Let's step through what's happening here...


  • A user visits the login page.
    • The server returns the login page's markup, which is displayed in the user's browser.
  • The user enters their credentials and clicks the Login button. A postback occurs.
    • The incoming request enters the ASP.NET pipeline.
    • The Application_Authenticate event fires. At this point, the ASP.NET runtime doesn't know who the user is, so User.Identity.IsAuthenticated = false
    • The login page's lifecycle beings
    • The Login control's Authenticate event fires and a forms authentication ticket is created because you set e.Authenticated to true.
    • The Login control's LoggedIn event fires. At this point, we're still on the same request, so User.Identity.IsAuthenticated is still false!

In short, the User object is set earlier in the ASP.NET pipeline, long before the requested ASP.NET page's code is executed. Now, on the subsequent visit, the ASP.NET runtime will see the forms authentication ticket and User.Identity.IsAuthenticated will be true, but not on this request.

I really hope this makes sense.

In any event, in the LoggedIn event handler there's no need to check if the user is authenticated - you already know they are! The LoggedIn event wouldn't fire otherwise. Also, you won't be able to get the username from User.Identity.Name. Instead, use LoginControlID.Username.

博文最后更新时间:


评论

  • tghosceck

    LuMCvY <a href="http://hmtxufhghefa.com/">hmtxufhghefa</a>, [url=http://qyctybfkgrtu.com/]qyctybfkgrtu[/url], [link=http://dkjkkuqxfztw.com/]dkjkkuqxfztw[/link], http://zzahotkmcays.com/

  • johnansog

    gUEEeK http://pills2sale.com/vjUe79ndRq341pIo

  • dobsonz

    YoApDi http://pills2sale.com/vjUe79ndRq341pIo

  • Florentino

    What do you want to do when you've finished? http://xnxxrating.online hentaihaven According to a filing on Monday with the U.S. District Courtin Bridgeport, Connecticut, the settlement resolves claimsagainst Stora Enso and the former Stora Enso North America Corpunit, which was sold in 2007 and is now known as NewPageWisconsin System Inc after going through bankruptcy.

  • Jarod

    Remove card http://tubeadvisor.online hqporner Final lesson today. I&rsquo;ve got my flamenco dress on and a pair of heels that produce the right &lsquo;&lsquo;clunk&rsquo;&rsquo;. I think I&rsquo;ve got the dances and, yes, I&rsquo;m sure a fierce Spanish passion is growing within me. Jesus has saved the day and he says I&rsquo;m almost VG!

  • Archie

    Did you go to university? http://xnxxrating.online dinotube On this week's Daily News Fifth Yankees Podcast, Mark Feinsand sits down with reliever Dave Robertson to chat about his recent shoulder injury, Mariano Rivera's impressive September workload, the Yankees' chances of reaching the postseason as well as last week's rookie hazing.

发表评论

博客统计

访问量:5580963

博文总数:751 评论总数:920189

原创126 翻译20 转载605