Членство в ASP.NET: создание пользователя без requiresQuestionAndAnswer
Как я могу использовать метод CreateUser в классе членства, не задавая вопросов и ответов?
Я отключил его в web.config со следующей настройкой.
requiresQuestionAndAnswer="false"
Мне нужен вывод состояния из метода CreateUser, но перегрузка требует вопросов и ответов. Может ли кто-нибудь подсказать, как я могу это сделать?
Ответов (3)3
вам нужно установить параметры в 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"/>
Я пробовал это. Работает нормально. Спасибо
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.