Working Example

Feb 13, 2008 at 2:18 AM
Edited Feb 13, 2008 at 3:07 AM
This message was originally my asking for a working example. Since then I created another blank web solution and got it to work.

I should have a working example soon and will post a link when it's done.
Feb 13, 2008 at 6:25 AM
I've added profile properties in the web.config for FirstName and LastName and created the code to save those items in the _CreatedUser event but nothing saves.

I created a Profiles.config file and nothing is being saved to that file.

Any help on this would be appreciatd.
Coordinator
Feb 13, 2008 at 8:15 AM
Edited Feb 13, 2008 at 8:15 AM
Hi,
Actually you don't need to create Profile.config file manually.
Just enable profile in web.config file and when something is saved profiles file will be created automatically when is needed.
If that not happened to you means you have not proper configured profile usage.
First here is an example of how should you web.config section for profile look like:

<profile enabled="true" defaultProvider="XmlProfileProvider">
    <providers>
        <clear />
        <add applicationName="<YOU_APPNAME_HERE>" name="XmlProfileProvider" type="Artem.Web.Security.XmlProfileProvider" />
    </providers>
    <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
     </properties>
</profile>

Then if you saving those setting in profile for anonymous users try enabling anonymous identification in web.config, and that should look like:

<anonymousIdentification enabled="true"/>
<profile enabled="true" defaultProvider="XmlProfileProvider">
    <providers>
        <clear />
        <add applicationName="<YOU_APPNAME_HERE>" name="XmlProfileProvider" type="Artem.Web.Security.XmlProfileProvider" />
    </providers>
    <properties>
        <add name="FirstName" type="string"/>
        <add name="LastName" type="string"/>
     </properties>
</profile>

Hope this helps.
Velio
Feb 13, 2008 at 2:33 PM
Thanks Velio,

My profile section was exactly the same as yours. So I copy/pasted the profile.config you emailed me and put it in my App_Data folder. Then created a new user. The profile.config file didn't change.

So then I copy/pasted the config section you sent me and put it in the web.config and registered a new user, still didn't work. It doesn't seem to be updating the Profiles.config file at all.

Here is the code I'm using on the register.aspx page to handle updating the profile, is it correct?

Private Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
'Create empty profile for new user#
Dim p As ProfileCommon = DirectCast(ProfileCommon.Create(CreateUserWizard1.UserName, True), ProfileCommon)

'Populate profile with data from form
p.FirstName = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"), TextBox).Text
p.LastName = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName"), TextBox).Text

'Save profile information
p.Save()

Roles.AddUserToRole(CreateUserWizard1.UserName, "Editors")
End Sub

BTW I get no errors at build or runtime.
Coordinator
Feb 14, 2008 at 7:45 AM
Edited Feb 14, 2008 at 7:47 AM
Hi,
Very weird indeed.
Have you checked if Profile.config file is read only? It shouldn't be.
I'll check out that issue and try reproducing it.
Regards