ASP.NET Membership Create User without requiresQuestionAndAnswer

How can I use the CreateUser method in the Membership class without having to assign a question and answer?

I have disabled it in the web.config with the following setting.

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 2

you need to set parameters in web.config

<system.web>
<membership>
<providers>

<add name="YOURMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="con"  minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Clear" applicationName="YourAppName" maxInvalidPasswordAttempts="2147483647"/>

I tried this. Its working Fine. Thanks

Method 3

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x