Error when trying to create member programatically
when trying to create a member programatically using:
var m = System.Web.Security.Membership.CreateUser("testuser", "testpassword")
I get the error: Object reference not set to an instance of an object.
I am using v4.7 which has been upgraded various times from 3.? through 4 and 4.5.
I can create members throught the UI.
I did have to do a fair bit of config file editing to get the search for members facility to work so I'm guseeing I'm missing an entry somewhere. Anyone got any ideas?
You need to use the Umbraco Membership Provider method, rather than the built in Windows Security one. There's an example of creating members programmatically in Umbraco here: http://www.nibble.be/?p=20
I would like to point out that I got this reply from a CORE member on the topic a while back. I've been using the built membership methods in the .NET library quite successfully, with the exception of having to impliment custom proprties in the Umbraco Membership.
I think the problem might rely in your web.config file. Did you specify the "defaultMemberTypeAlias" attribute in the membership provider definition? Or does the one specified exist in your Umbraco backend?
How do you create a member with a specified type using the new ASP.NET based API? It seems you can only create one with the defaultMemberTypeAlias looking at that?
Also, what are the roles? Are they the Member Groups?
Error when trying to create member programatically
when trying to create a member programatically using:
var m = System.Web.Security.Membership.CreateUser("testuser", "testpassword")
I get the error: Object reference not set to an instance of an object.
I am using v4.7 which has been upgraded various times from 3.? through 4 and 4.5.
I can create members throught the UI.
I did have to do a fair bit of config file editing to get the search for members facility to work so I'm guseeing I'm missing an entry somewhere. Anyone got any ideas?
You need to use the Umbraco Membership Provider method, rather than the built in Windows Security one. There's an example of creating members programmatically in Umbraco here: http://www.nibble.be/?p=20
Hope that helps!
:)
Tim
thanks very much for the info, I've got it working now.
However, there are the following warnings:
umbraco.cms.businesslogic.member.Member.MakeNew(...) is now depracated
umbraco.cms.businesslogic.member.Member.AddGroup(int) is obsolete use System.Web.Security.Roles.AddUserToRoles.
Any thoughts on this?
Andy
I would like to point out that I got this reply from a CORE member on the topic a while back. I've been using the built membership methods in the .NET library quite successfully, with the exception of having to impliment custom proprties in the Umbraco Membership.
It could be cleaned up a little, but this has worked well:
Thanks, I'll give that a try.
Hi,
I think the problem might rely in your web.config file. Did you specify the "defaultMemberTypeAlias" attribute in the membership provider definition? Or does the one specified exist in your Umbraco backend?
See this wiki post for more information: our.umbraco.org/.../umbracomembershipprovider-properties
Hope this helps
Cheers,
Michael.
Thanks for your tip on 'defaultMemberTypeAlias', saved me a lot of time!
You're welcome :-) !
How do you create a member with a specified type using the new ASP.NET based API? It seems you can only create one with the defaultMemberTypeAlias looking at that?
Also, what are the roles? Are they the Member Groups?
is working on a reply...