从 web.config 读取成员资格部分 [英] Reading membership section from web.config

查看:30
本文介绍了从 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;

这将返回一个 int,指定所需的最小密码长度.

And that would return an int specifying the minimum required password length.

这篇关于从 web.config 读取成员资格部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆