自定義成員,我有CustomMembership項目類,並在課堂上使用此代碼:集minRequiredPasswordLength在web.config中
private static int _MinRequiredPasswordLength;
public static int MinRequiredPasswordLength
{
set { _MinRequiredPasswordLength = value; }
get { return _MinRequiredPasswordLength; }
}
,並在web.config中
<membership defaultProvider="CustomMembership">
<providers>
<clear />
<add name="CustomMembership" type="Project1.Code.CustomMembership, Project1, Version=1.0.0.0, Culture=neutral" connectionStringName="PConn" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
和使用集合成員資格此代碼獲取minRequiredPasswordLength:
MinRequiredPasswordLength.Text = CMembership.MinRequiredPasswordLength.ToString();
但得到'0'!我想要'6'。
我用這個代碼,但得到「0」 –
你有「0」,因爲你永遠不會對你的公共屬性設置值'MinRequiredPasswordLength' – AlexB
我設置在web.config中 –