Wrox Programmer Forums
|
BOOK: Professional ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Professional ASP.NET 4 in C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470502204
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2011, 11:59 AM
Registered User
 
Join Date: Sep 2011
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default 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.
 
Old September 26th, 2011, 02:13 PM
Registered User
 
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

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.
 
Old September 26th, 2011, 02:15 PM
Registered User
 
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?


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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
[newbie] ProfileCommon ? jon80 BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 1 March 14th, 2009 02:43 PM
ShoppingCart is not a member of ProfileCommon sstuber BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 May 21st, 2008 04:55 PM
Why docodeSubDirectories cause ProfileCommon error Joe@Tulsa BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 March 3rd, 2008 12:15 PM
ProfileCommon not defined error flyer ASP.NET 2.0 Basics 0 September 26th, 2007 08:07 PM
ProfileCommon Compilation Error bleitner ASP.NET 2.0 Professional 1 January 15th, 2006 03:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.