ASP.NET Membership Create User without requiresQuestionAndAnswer

核能气质少年 提交于 2019-12-29 07:27:07

问题


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?


回答1:


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




回答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




回答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.



来源:https://stackoverflow.com/questions/595957/asp-net-membership-create-user-without-requiresquestionandanswer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!