p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=554)
-   -   ProfileCommon not Supported (http://p2p.wrox.com/showthread.php?t=85085)

Chris_Alis September 19th, 2011 11:59 AM

ProfileCommon not Supported
 
So in trying to wire up new properties for the Profile, I've discovered that ProfileCommon and Profile are not supported in VS 2010 . I'd like suggestions on the best strategy for handling Profile info in Web Applications ( I hear it's still supported the way the book presents it in Web Sites.)

If I write a class for my own ProfileCommon 'Like' class, inheriting ProfileBase, will it save all my properties to the profile provider just by executing the pc.save method ?

Or is it better to just go all in and write it with my own database table and save method .....just skipping the whole Profile system ?

Can't believe they hype this feature and then disconnect it.

VB.net appreciated.
Thanks for any insights.

Chris_Alis September 26th, 2011 02:13 PM

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

pf.Save()

Debug.Print(name)



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.

Chris_Alis September 26th, 2011 02:15 PM

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?


Code:


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

      FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)


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

 pf.SetPropertyValue("FirstName", txtFirstName.Text)
 
Dim name As String = pf.GetPropertyValue("FirstName").ToString

pf.Save()
 
Debug.Print(name)



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.


All times are GMT -4. The time now is 11:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.