0

I am doing a CustomProfile for a web project and so far I had managed until now. I used this guide: http://msdn.microsoft.com/en-us/magazine/cc163457.aspx and followed it. My project is VB.NET so I followed the instructions for C# files. I created a custom table, adjusted it to my needs and I am facing two problems.

    Sub SiteCreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim UserProfile As ProfileCommon = Profile.GetProfile(SiteCreateUserWizard.UserName)
    UserProfile.FirstName = FirstNameTextBox.Text
    UserProfile.LastName = LastNameTextBox.Text
    UserProfile.Branch = branch.SelectedValue

    UserProfile.ProfileVersion = Microsoft.Samples.SqlTableProfileProvider.ProfileVersion
    UserProfile.Save()
End Sub

The UserProfile.ProfileVersion line is giving me an error. "Error 7 'ProfileVersion' is not a member of 'ProfileCommon'" and "Error 8 'ProfileVersion' is not a member of 'Microsoft.Samples.SqlTableProfileProvider'."

If I comment this line it works to a certain degree. As soon as I try to register an user it gives me the following error: Parser Error Message: Unrecognized config attribute:profileVersion. This is my webconfig file....

    <profile defaultProvider="MyCustomProfileProvider">
  <providers>
    <add name="MyCustomProfileProvider" type="Microsoft.Samples.SqlTableProfileProvider" connectionStringName="LocalSqlServer" table="CustomProfile" applicationName="/"  profileVersion="1" />



  </providers>

  <properties>
    <add name="FirstName" type="string" defaultValue="[null]" customProviderData="FirstName;nvarchar" />
    <add name="LastName" type="string" defaultValue="[null]" customProviderData="LastName;nvarchar" />
    <add name="MaternallastName" type="string" defaultValue="[null]" customProviderData="MaternalLastName;nvarchar" />
    <add name="Branch" type="string" defaultValue="[null]" customProviderData="Branch;nvarchar" />

  </properties>

If I take out the ProfileVersion it doesn't even work. Any suggestions are gladly welcome. I've been stuck on this half the day, heh.

</profile>
Lord Relix
  • 922
  • 5
  • 23
  • 50
  • Are you limited to ASP.NET 2.0 or are you on a later version? – Luke Baughan Apr 25 '13 at 19:56
  • Actually I am running 4.5. I just didn't find a suitable/simpler alternative. And trust me... I spent a day looking for options and I found a LOT. Just didn't know which was better to pick so i picked the one with the clearer instructions. If you have any "modern" suggestion its more than welcome. This is my first time working with profiles and stuff so i am a little lost. – Lord Relix Apr 25 '13 at 20:05
  • I guess I should add I don't save as a normal profile because I need to query some of the user data in some instances. – Lord Relix Apr 25 '13 at 20:29
  • 1
    Awesome, so glad you said that! OK so the new way is SimpleMembershipProvider its MUCH better and easier and supports OAuth out of the box to enable "Login via Facebook" type logins as well! First read this article here which explains why the created it and how its better http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx . As for providing a profile scheme checkout this post http://stackoverflow.com/questions/12352218/how-do-i-manage-profiles-using-simplemembership – Luke Baughan Apr 25 '13 at 20:43
  • This is also a useful post http://stackoverflow.com/questions/13224405/update-custom-user-profile-fields-with-simplemembershipprovider – Luke Baughan Apr 25 '13 at 20:45
  • Oh. That seems pretty darned good.. Can youn make a separate post so with this info so I can mark as Answered? It seems pretty easy to use so i will read into it further. – Lord Relix Apr 25 '13 at 20:54
  • Have elevated comments to an answer - thanks very much for the accept! – Luke Baughan Apr 25 '13 at 21:20

1 Answers1

0

If you're using ASP.NET 4.5 the new way is SimpleMembershipProvider its MUCH better and easier and supports OAuth out of the box to enable "Login via Facebook" type logins as well! First read this article . As for providing a profile scheme checkout this post.

Another post to look at is here and explains other ways of accessing additional user/profile based info!

Community
  • 1
  • 1
Luke Baughan
  • 4,658
  • 3
  • 31
  • 54
  • Quick question (if you can answer)... any non MVC guides? I am using WebForms (tight schedule and I am a newbie to MVC) so a nice guide for WebForms would be great. I've found a few but nowhere as good as the MVC type. (I should really get to learning MVC soon haha) – Lord Relix Apr 25 '13 at 21:44
  • Wow that took some finding - right this is the best I could find, not sure if it still IS SimpleMembership BUT it is the latest WebForms approachs and looks very much the same! http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/membership-and-administration – Luke Baughan Apr 25 '13 at 22:00
  • Actually Ive just been back and fully read that article its really not that great. The CLOSEST I could find was this http://blog.osbornm.com/2010/07/21/using-simplemembership-with-asp.net-webpages/ which is a link from the Jon Galloway page its for WebPages but I believe it should hold up with a little tinkering perhaps! – Luke Baughan Apr 25 '13 at 22:13
  • Hah, alright gonna try this out. Yeah I definitely need to move on to MVC Enviroment haha. Thanks a million bUKaneer :) – Lord Relix Apr 25 '13 at 23:18
  • No problem at all - I would defintly switch to MVC, my bread and butter was Web Forms for 10+ years and I love it dearly BUT I started switching over to MVC a while ago and to be honest Ive not looked back. Its a BIG fairly steep learning curve but well worth it everything flows better and its very flexible ;o) WebAPI is also a blast btw! – Luke Baughan Apr 25 '13 at 23:29