• <bdo id='LKOYx'></bdo><ul id='LKOYx'></ul>
      1. <legend id='LKOYx'><style id='LKOYx'><dir id='LKOYx'><q id='LKOYx'></q></dir></style></legend>
      2. <small id='LKOYx'></small><noframes id='LKOYx'>

        <tfoot id='LKOYx'></tfoot>
        <i id='LKOYx'><tr id='LKOYx'><dt id='LKOYx'><q id='LKOYx'><span id='LKOYx'><b id='LKOYx'><form id='LKOYx'><ins id='LKOYx'></ins><ul id='LKOYx'></ul><sub id='LKOYx'></sub></form><legend id='LKOYx'></legend><bdo id='LKOYx'><pre id='LKOYx'><center id='LKOYx'></center></pre></bdo></b><th id='LKOYx'></th></span></q></dt></tr></i><div id='LKOYx'><tfoot id='LKOYx'></tfoot><dl id='LKOYx'><fieldset id='LKOYx'></fieldset></dl></div>

        如何在 ASP.NET 5 MVC 6 (vNext) 中定义 Identity 的密码规则?

        时间:2023-07-11
          <tbody id='3RbHJ'></tbody>

        <legend id='3RbHJ'><style id='3RbHJ'><dir id='3RbHJ'><q id='3RbHJ'></q></dir></style></legend>
          <bdo id='3RbHJ'></bdo><ul id='3RbHJ'></ul>
              <i id='3RbHJ'><tr id='3RbHJ'><dt id='3RbHJ'><q id='3RbHJ'><span id='3RbHJ'><b id='3RbHJ'><form id='3RbHJ'><ins id='3RbHJ'></ins><ul id='3RbHJ'></ul><sub id='3RbHJ'></sub></form><legend id='3RbHJ'></legend><bdo id='3RbHJ'><pre id='3RbHJ'><center id='3RbHJ'></center></pre></bdo></b><th id='3RbHJ'></th></span></q></dt></tr></i><div id='3RbHJ'><tfoot id='3RbHJ'></tfoot><dl id='3RbHJ'><fieldset id='3RbHJ'></fieldset></dl></div>

            1. <tfoot id='3RbHJ'></tfoot>

                <small id='3RbHJ'></small><noframes id='3RbHJ'>

                • 本文介绍了如何在 ASP.NET 5 MVC 6 (vNext) 中定义 Identity 的密码规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  ASP.NET 5 中提供的默认身份提供程序默认有非常严格的密码规则,需要一个小写字符、一个大写字符、一个非字母数字字符和一个数字.我正在寻找一种方法来更改提供商的密码要求.

                  The default Identity provider provided in ASP.NET 5 has very strict password rules by default, requiring a lower case character, an upper case character, a non-alphanumeric character, and a number. I am looking for a way to change the password requirements for the provider.

                  以前在 ASP.NET 4 中,可以通过 Web.config XML 文件配置提供程序,如 以前回答过.但是 ASP.NET 5 使用新的基于代码的配置模式,不清楚如何配置身份.

                  Previously in ASP.NET 4, the provider could be configured via the Web.config XML file, as previously answered. However ASP.NET 5 uses the new code based configuration pattern and it is unclear how to configure the identity.

                  如何更改我的应用程序的密码要求?

                  How can I change the password requirements for my application?

                  推荐答案

                  我实际上最终弄清楚了这一点,事实证明您需要为 AddDefaultIdentity 提供一个合适的 lambda 表达式来配置它提供的 IdentityOptions.这是在 Startup 类的 ConfigureServices 方法中完成的,如下所示:

                  I actually ended up figuring this out, it turns out you need to supply AddDefaultIdentity with a suitable lambda expression that configures the IdentityOptions it provides. This is done inside the ConfigureServices method within the Startup class, like so:

                  public class Startup {
                      public void ConfigureServices(IServiceCollection services) {
                  
                          // Add Identity services to the services container.
                          services.AddDefaultIdentity<ApplicationIdentityDbContext, ApplicationUser, IdentityRole>(Configuration,
                              o => {
                                  o.Password.RequireDigit = false;
                                  o.Password.RequireLowercase = false;
                                  o.Password.RequireUppercase = false;
                                  o.Password.RequireNonLetterOrDigit = false;
                                  o.Password.RequiredLength = 7;
                              });
                      }
                  }
                  

                  更新 2:

                  上述在框架的 beta1 版本中是正确的,在最新的 rc1 beta5 中它略微更改为:

                  The above was true in the beta1 versions of the framework, in the latest rc1 beta5 it has changed slightly to:

                  services.AddIdentity<ApplicationUser, IdentityRole>(o => {
                      // configure identity options
                      o.Password.RequireDigit = false;
                      o.Password.RequireLowercase = false;
                      o.Password.RequireUppercase = false;
                      o.Password.RequireNonAlphanumeric = false;
                      o.Password.RequiredLength = 6;
                  })
                  .AddEntityFrameworkStores<ApplicationIdentityDbContext>()
                  .AddDefaultTokenProviders();
                  

                  这篇关于如何在 ASP.NET 5 MVC 6 (vNext) 中定义 Identity 的密码规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 ASP.NET Core MVC 中的视图中格式化日期 下一篇:ASP.NET Core 在 Web API 中处理自定义响应/输出格式的方法

                  相关文章

                • <legend id='Q0zzF'><style id='Q0zzF'><dir id='Q0zzF'><q id='Q0zzF'></q></dir></style></legend>

                  <small id='Q0zzF'></small><noframes id='Q0zzF'>

                    <tfoot id='Q0zzF'></tfoot>
                      <bdo id='Q0zzF'></bdo><ul id='Q0zzF'></ul>
                  1. <i id='Q0zzF'><tr id='Q0zzF'><dt id='Q0zzF'><q id='Q0zzF'><span id='Q0zzF'><b id='Q0zzF'><form id='Q0zzF'><ins id='Q0zzF'></ins><ul id='Q0zzF'></ul><sub id='Q0zzF'></sub></form><legend id='Q0zzF'></legend><bdo id='Q0zzF'><pre id='Q0zzF'><center id='Q0zzF'></center></pre></bdo></b><th id='Q0zzF'></th></span></q></dt></tr></i><div id='Q0zzF'><tfoot id='Q0zzF'></tfoot><dl id='Q0zzF'><fieldset id='Q0zzF'></fieldset></dl></div>