View Single Post
  #2 (permalink)  
Old September 26th, 2011, 02:13 PM
Chris_Alis Chris_Alis is offline
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2011
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Profile but not as documented

If you write a class and call it ProfileCommon and put it in a folder called App_Code you will get an error that says you are duplicating the class. VS2010 does generate code for a ProfileCommon class and stores it in a temp file. If you find it, and add it to your project, you get the same error , but indicating a new temp file. You can't use intellisense, but the profile system is working. But not the way the books document it.

Don't write a ProfileCommon class or other custom class. Add properties to the web.config as documented (just remember them so you can write your code without intellisense) The following code saved a custom property (FirstName) to the profile database (you may have to refresh your connection or close the table and reopen it to see it). The code was placed in the RegisterUser_CreatedUser method. On a new registerwizard first step page, I placed a textbox named txtFirstName. BTW, have you noticed that the Profile table is in the default database?

Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser

FormsAuthentication.SetAuthCookie(RegisterUser.Use rName, False)

Dim pf As ProfileBase = ProfileBase.Create(RegisterUser.UserName)

pf.SetPropertyValue("FirstName", txtFirstName.Text)

Dim name As String = pf.GetPropertyValue("FirstName").ToString



End Sub

I haven't tried this targeting anyother versions of .NET, like 3.5, but I assume it's all a queston of how VS2010 is handling this issue, not the .NET version.