从web.config读取成员资格部分 [英] Reading membership section from web.config
问题描述
到目前为止,我已经创建了一个自定义MembershipProvider类,但是到目前为止,我不确定如何从web.config文件中读取配置设置.
I have created a custom MembershipProvider class, so far so good, however, I am not sure how to read the configuration settings from the web.config file.
我尝试从Google和Stackoverflow进行搜索,似乎有人也在体验我的 问题并被询问,但没有给出答案.
I tried to search from Google and Stackoverflow, seems like someone also experiencing my problem and asked, but no answer has been given.
这应该很简单,但是我在Web开发中还是一个新手,因此从web.config中读取设置对我来说似乎太过技术化了.
It should be a simple thing, but I am very new in web development, so reading settings from web.config seems away too technical to me.
这是我的设置:
<membership defaultProvider="CustomMembershipProvider">
<providers>
<clear/>
<add name="CustomMembershipProvider"
type="Test.Models.CustomMembershipProvider,Test"
passwordFormat="Hashed"
connectionStringName="ApplicationServices"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="0"
maxInvalidPasswordAttempts="5"
enablePasswordReset="false"
enablePasswordRetrieval="false"
requiresQuestionAndAnswer="false"
applicationName="/"/>
</providers>
</membership>
我想阅读minRequiredPasswordLength
设置,请提供帮助.
I would like to read the minRequiredPasswordLength
setting, please assist.
推荐答案
由于已将其设置为默认提供程序,因此足以:
As this is set as your default provider it should be enough to:
int i = Membership.MinRequiredPasswordLength;
这将返回一个整数,该整数指定所需的最小密码长度.
And that would return an int specifying the minimum required password length.
这篇关于从web.config读取成员资格部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!