MySQL 的 ASP.NET 成员资格/角色提供程序? [英] ASP.NET Membership/Role providers for MySQL?

查看:45
本文介绍了MySQL 的 ASP.NET 成员资格/角色提供程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 ASP.NET 成员资格/角色一点也不熟悉.这是我第一次使用它,也是我第一次尝试 ASP.NET MVC.当我为 MVC 创建我的第一个项目时,它给了我一个可爱的模板来创建一个帐户.我很高兴看到我不必手动执行此操作.但是,它失败了,因为它无法连接到 SQL Server.我没有 SQL Server,我有 MySQL.有什么简单的方法可以让这个系统改用 MySQL,还是我必须创建自己的身份验证?

I am not at all familiar with ASP.NET membership/roles. This is my first time using it, and my first time trying ASP.NET MVC. When I create my first project for MVC, it gives me a lovely template to create an account. I was excited to see that I did not have to do this manually. However, it failed because it cannot connect to SQL Server. I do not have SQL Server, I have MySQL. Is there any easy way I can get this system to use MySQL instead, or will I have to create my own authentication?

推荐答案

明白了!使用 MySql Connector/Net 的 6.2.2.0 版,请按照以下步骤操作...

Got it figured out! Using version 6.2.2.0 of MySql Connector/Net, follow these steps...

  • 添加对 MySql.Web.dll 的引用
  • 将您在 web.config 中的 更改为:

<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear/>
    <add name="MySqlMembershipProvider"
         type="MySql.Web.Security.MySQLMembershipProvider,
               MySql.Web, Version=6.2.2.0, Culture=neutral,
               PublicKeyToken=c5687fc88969c44d"
         autogenerateschema="true"
         connectionStringName="NAME_OF_YOUR_CONN_STRING"
         enablePasswordRetrieval="false"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="false"
         requiresUniqueEmail="false"
         passwordFormat="Hashed"
         maxInvalidPasswordAttempts="5"
         minRequiredPasswordLength="6"
         minRequiredNonalphanumericCharacters="0"
         passwordAttemptWindow="10"
         passwordStrengthRegularExpression=""
         applicationName="/"
     />
  </providers>
</membership>

  • 运行项目 |ASP.NET 配置工具并单击安全"选项卡进行测试
  • 在 ASP.NET 3.5、MySQL Server 5.1 版、Windows XP 64 位上测试
  • 这篇关于MySQL 的 ASP.NET 成员资格/角色提供程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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