November Happy Hour will be moved to Thursday December 5th.

User registration

Vote:
 

I'm looking at the code user registration in the public templates and it uses the Create user-wizard from the asp.net framework. What I can't figure out is where to find the insert-command? Where is it located?

#38969
Apr 27, 2010 9:10
Vote:
 

The wizard calls the Membership-providers implementation of CreateUser().

/johan

 

#38972
Apr 27, 2010 11:36
Vote:
 

Can I find this and alter it? I'd like to add a variable to the registration.

#38973
Apr 27, 2010 11:41
Vote:
 

You can hook the CreatingUser event of the CreatUserWizard control.

/johan

#38974
Apr 27, 2010 11:43
Vote:
 

Use the ASP.NET membership profile for this: http://www.4guysfromrolla.com/articles/101106-1.aspx

#38975
Apr 27, 2010 11:44
Vote:
 

I've read the article and done some further research but I don't understand how it works. I've added a line to the web.config that I want to use, it's <add name="Location" type="System.Int" />. I found another article telling me how to go about but I still can't seem to get it to work. I get stuck on not knowing where to find the ProfileCommon-class.

http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

#38981
Apr 27, 2010 14:11
Vote:
 

Ah, yeah you need to create the ProfileCommon class, you can use this tool to generate it: http://code.msdn.microsoft.com/WebProfileBuilder. The article uses the WebSite project which gets compiled during runtime, EPiServer uses the web application project which you need to compile into a dll file before (hence needing to add the ProfileCommon class manually.

Hope this helps.

Frederik

#38983
Apr 27, 2010 14:30
Vote:
 

I installed it and added the import-line to my project like he said in his blog post but still no Profile or ProfileCommon. Is there anything else that needs to be done?

#38991
Apr 27, 2010 15:44
Vote:
 

What happens after you build the project?

#39003
Apr 27, 2010 21:32
Vote:
 

Nothing in particular. It compiles.

What I've done so far is that I ran the installer for Web Profile Builder, added the <Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets" /> to my .csproj-file. The first time I ran the solution I got the question if I wanted to load the project for browsing or normally so I choose normally. When compiling nothing out of the ordinary happens and no sight of ProfileCommon.

Have I missed a step?

#39012
Apr 28, 2010 8:11
Vote:
 

I'm still stuck on this step. Has someone got a tip on how to get past it?

#39301
May 10, 2010 11:08
Vote:
 

I suggest you skip the ProfileCommon altogether and simply access the profiledata through the ProfileBase-class instead:

int location = (int)HttpContext.Current.Profile["Location"];

HttpContext.Current.Profile["Location"] = location;

/johan

#39305
May 10, 2010 11:41
Vote:
 

On what event do I set Location? I've tried OnCreatingUser and OnCreatedUser but I end up getting "This property can not be set for anonymous users".

#39310
Edited, May 10, 2010 14:53
Vote:
 

Yeah, in your web.config under the <profile><properties> section you should have the following:
<add name="Location" type="System.Int32" />

/johan

#39311
May 10, 2010 14:58
Vote:
 

I found it, sorry. I need to think before asking. :)

On what event do I set Location? I've tried OnCreatingUser and OnCreatedUser but I end up getting "This property can not be set for anonymous users".

#39312
May 10, 2010 15:01
Vote:
 

I'd hook up to the OnCreatedUser, and instead of using HttpContext.Current.Profile (which requires the user to be currently logged in),
use:

ProfileBase.Create(createUserWizard1.UserName)["Location"] = 10;

(assuming the CreateUserWizard control is named "createUserWizard1" )

/johan

#39313
May 10, 2010 15:07
Vote:
 

I tried this and when I try to get the Location on another page I always end up getting 0. Any idea on what could be the problem?

#39316
May 10, 2010 16:02
Vote:
 

You need to call Profile.Save() for changes to be committed to the profileprovider.

Also, for the profile to be available on the other page, the user must be logged in.

/johan

#39317
May 10, 2010 16:07
Vote:
 

Where do I locate Profile.Save? Is it HttpContext.Current.Profile.Save() ?

#39318
May 10, 2010 16:21
Vote:
 

If the user is not logged in, you could somehting like this:

ProfileBase userProfile = ProfileBase.Create("username");
userProfile["Location"] = 10;
userProfile.Save();

/johan

#39320
May 10, 2010 16:37
Vote:
 

Great, that did the trick!

Thanks a million!

#39321
May 10, 2010 16:42
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.