User registration


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

Apr 27, 2010 9:10

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



Apr 27, 2010 11:36

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

Apr 27, 2010 11:41

You can hook the CreatingUser event of the CreatUserWizard control.


Apr 27, 2010 11:43

Use the ASP.NET membership profile for this:

Apr 27, 2010 11:44

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.

Apr 27, 2010 14:11

Ah, yeah you need to create the ProfileCommon class, you can use this tool to generate it: 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.


Apr 27, 2010 14:30

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?

Apr 27, 2010 15:44

What happens after you build the project?

Apr 27, 2010 21:32

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?

Apr 28, 2010 8:11

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

May 10, 2010 11:08

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;


May 10, 2010 11:41

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".

Edited, May 10, 2010 14:53

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


May 10, 2010 14:58

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".

May 10, 2010 15:01

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

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

(assuming the CreateUserWizard control is named "createUserWizard1" )


May 10, 2010 15:07

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?

May 10, 2010 16:02

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.


May 10, 2010 16:07

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

May 10, 2010 16:21

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

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


May 10, 2010 16:37

Great, that did the trick!

Thanks a million!

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.