Re: ASP.NET 2.0 Profile/Membership/Forms Authentication - Manual Login



Hi,

well - the user is not authenticated yet - he will be after the next roundtrip after the Authenticate_Request event.

One option would be to set these values in the anonymous profile and handle the Profile_Migrate event to migrate the anon profile to the authenticated profile on the next roundtrip

Another thing i haven't tried is: Profile looks for Context.User.Identity.Name and IsAuthenticated - i am not sure at which stage he does that - maybe you can fake that by creating a GenericIdentity / Principal and set this to Context.User before calling the Profile API.

tell us if that worked for you.


--------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com

I'm working on an ASP.NET 2.0 web app using C# and SQL Server 2000.
I've created a multi-step user profile page using the wizard web
control and when the user clicks on the finish button on the final
screen I have code in the click event on the server that does the
following:

- Creates a new user using Membership.CreateUser()
- Adds this new user to a default role using Roles.AddUserToRole()
- Inserts the other form fields into various tables in the DB
- Sends a confirmation email
What I'd like to do now is to add some of the fields (i.e. First Name
and Last Name) to the Profile class (which is already setup properly
via my web.Config file).  I'm doing the following:

Profile.FirstName = txtFirstName.Text;
Profile.LastName = txtLastName.Text;
However, I'm getting a Provider.ProviderException stating "This
property cannot be set for anonymous users.".  Checking the
NewUserInfo properties it appears this newly created user is logged in
and shouldn't be anonymous.

So, given the brief overview of what I've done and how I've
accomplished it, how do I now authenticate this newly created user
behind the scenes so that I can associate this profile data with this
user?  When all is said and done, I do not mind if the user is
pre-authenticated and pre-authorized after following all of my
registration steps.   Who'd want to fill out one more form just to
login at this point?  :)

beaudetious



.