views:

1148

answers:

2

Hi, can someone tell me how I can use the CreateUser method in the Membership class without having to assign a question and answer?

I have disabled it in the web config: requiresQuestionAndAnswer="false"

I need the status output from the CreateUser method but the overload requires a question and answer, can anyone suggest how I can go about this? Thanks.

+3  A: 

I haven't tried this, but have you tried just passing null for those two parameters?

Quintin Robinson
No problem glad it worked, just did some MSDN research and was going to post some info supporting this, but glad you got it!
Quintin Robinson
A: 

As another answerer mentioned, you just pass null in instead of "", or string.Empty.

When I first discovered this I though that the developers hadn't heard of string.IsNullOrEmpty, and that we were venturing into WTF territory.

But of course, in their wisdom, they realised that null is conceptually different to an empty string, and in this case, when dealing with input from a user, we want to tell them their question is invalid if it's not specified.

Khanzor