views:

50

answers:

1

I use FormsAuthentication.RedirectFromLoginPage(userName.Trim(), false); to set the User.Identity.Name field that I reference later. When I execute this line, the User.Identity object does not update at all; it contains whatever it was previously set to. All the documentation I see online says this should update my User.Identity object with the correct name, but I don't see that happening.

I have the web config set up properly with the following lines:

<authentication mode="Forms">
    <forms name="formsauth" loginUrl="Login.aspx" protection="All" timeout="60">
    </forms>
</authentication>
<authorization>
    <deny users="?"/>
</authorization>

I am relatively new to this stuff, so any help is appreciated. Thanks!

+1  A: 

It will be updated on the next request but not on the next line following it. RedirectFromLoginPage sets an authentication cookie in the client browser that will be read upon the next client request and you will see the User.Identity.Name property updated. Updating this property in the same HTTP request is meaningless as you already know that the user passed authentication as you called the method.

Darin Dimitrov
Thanks Darin! I had a check in the same request later on to check if the Session username matched the User.Identity.Name, but I'm not really sure why it was there (I didn't write it). Looks Like I should be able to take it out. Thanks again!
Kevin