从web.config文件在C#中阅读部分成员 [英] Reading membership section from web.config in C#
问题描述
我创建了一个自定义的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.
我试图从谷歌和#2进行搜索,好像也有人遇到我的
问题问过,但没有答案已经给出。
I tried to search from Google and Stackoverflow, seems like someone also experiencing my problem and asked, but no answer has been given.
这应该是一个简单的事情,但我在网络的发展非常新,所以从阅读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
设置请协助。
非常感谢在前进。
推荐答案
由于这是设置为默认的供应商应该是足够的:
As this is set as your default provider it should be enough to:
int i = Membership.MinRequiredPasswordLength;
这将返回一个int,指定所需的最小密码长度。
And that would return an int specifying the minimum required password length.
这篇关于从web.config文件在C#中阅读部分成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!