asp .net 4.0 会员资格和 mysql

发布于 2024-10-28 18:23:05 字数 207 浏览 6 评论 0原文

我们将在 Visual Studio 2010 中开发 ASP .NET Web 应用程序。我们使用 ASP .NET 会员提供程序进行身份验证。默认情况下,当我在 Visual Studio 2010 中创建项目时,它会为 sql server 提供程序生成身份验证代码,我需要将其更改为 MySQL 提供程序。谁能指导我,是否可以默认使用 mysql 创建 Web 应用程序?如果可能的话怎么办?

We are going to develop asp .net web application in visual studio 2010. we are using asp .net membership provider for the authentication. By default when i create project in visual studio 2010, it generates authentication code for the sql server provider and i needed to change it to MySQL provider. can anyone please guide me, is it possible to create web application by default using mysql ? if it is possible then how can it be done ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾冷 2024-11-04 18:23:05

假设您从头开始...

您要做的第一件事是获取最新版本的 MySQL 连接。这将在您的应用程序中充当 MySQL 的 ADO.NET 驱动程序。

接下来是在应用程序配置中配置提供程序。 IT 通常看起来像这样:

<add name="MySqlMembershipConnection"
connectionString="Data Source=server_name;user id=username;password=password
database=database_name;" providerName="MySql.Data.MySqlClient"/>

providerName 在这里很重要。这将表明您的提供商是 MySQL。下一部分是会员提供者。它的类型将为MySql.Web.Security.MySQLMembershipProvider, mysql.web,对于roleManager,它的类型将为MySql.Web.Security.MySQLRoleProvider, mysql.web

Assuming you are starting from scratch...

The first thing you will want to do is get the latest version of MySQL Connect. This will act as the ADO.NET Driver for MySQL in your application.

Next is to configure the provider in your application configuration. IT will typically look something like this:

<add name="MySqlMembershipConnection"
connectionString="Data Source=server_name;user id=username;password=password
database=database_name;" providerName="MySql.Data.MySqlClient"/>

The providerName is what's important here. This will indicate that your provider is MySQL. The next part is the membership provider. It's type will be MySql.Web.Security.MySQLMembershipProvider, mysql.web, and for the roleManager it will be MySql.Web.Security.MySQLRoleProvider, mysql.web.

咆哮 2024-11-04 18:23:05

有许多提供程序支持此功能,您可以在此处阅读它们并选择最适合您的提供程序:

http://dev.mysql.com/tech-resources/articles/dotnet/index.html#ADO.NET

There are a number of providers which support this, you can read about them and choose which is best for you here:

http://dev.mysql.com/tech-resources/articles/dotnet/index.html#ADO.NET

思念绕指尖 2024-11-04 18:23:05

我希望这会有所帮助,我已经做了类似的事情,但使用的是 Visual Studios 2012 Express for Web。

首先在您的项目引用中包括“MySql.Data”和“MySql.Web”dll。

完成此操作后,您将需要强名称实用程序从 MySql.Web.dll 获取公钥令牌。

您应该得到类似这样的内容(公钥令牌位于底部):


sn of MySql.Web.dll
C:\Program Files (x86)\MySQL\Connector NET 6.6.5\Assemblies\v4.0\MySql.Web.dll
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>sn -Tp MySql.Web.dll

Microsoft (R) .NET Framework 强名称实用程序版本 4.0.30319.33440
版权所有 (c) Microsoft Corporation。版权所有。

公钥(哈希算法:sha1):
0024000004800000940000000602000000240000525341310004000001000100d973bda91f7175
2c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a
519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e
10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c
886b3ee1

公钥令牌是 c5687fc88969c44d


如果右键单击 dll,它还会为您提供 dll 的版本。您需要将版本和公钥令牌放入 web.config 文件中。

因此,您的 web.config 文件应如下所示:

          <membership defaultProvider="MySqlMembershipProvider" >
            <providers>
              <clear/>
              <add name="MySqlMembershipProvider"
                   type="MySql.Web.Security.MySQLMembershipProvider,                 
                   MySql.Web, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"

                   autogenerateschema="true"
                   connectionStringName="AdminConnString"
                   enablePasswordRetrieval="false"
                   enablePasswordReset="true"
                   requiresQuestionAndAnswer="false"
                   requiresUniqueEmail="false"
                   passwordFormat="Hashed"
                   maxInvalidPasswordAttempts="5"
                   minRequiredPasswordLength="6"
                   minRequiredNonalphanumericCharacters="0"
                   passwordAttemptWindow="10"
                   passwordStrengthRegularExpression=""
                   applicationName="/"
                   />
            </providers>
          </membership>

请注意,在添加名称胡萝卜中,我引用了公钥令牌和 dll 的版本。

这几乎可以帮助您链接 asp.net 应用程序以使用 MySQL Membership Provider。

看看下面的视频,它几乎描述了我刚才所说的内容:
https://www.youtube.com/watch?v=NN4y_88vNvo

显示如何链接ASP.NET 与 MySQL 的成员资格。

I hope this helps, I have done something similar but using Visual Studios 2012 Express for Web.

First in your project references include the "MySql.Data" and "MySql.Web" dll's.

After doing that you're going to need the strong name utility to get the Public Key Token from the MySql.Web.dll.

You should get something like this (the public key token is at the bottom):


sn of MySql.Web.dll
C:\Program Files (x86)\MySQL\Connector NET 6.6.5\Assemblies\v4.0\MySql.Web.dll
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>sn -Tp MySql.Web.dll

Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.

Public key (hash algorithm: sha1):
0024000004800000940000000602000000240000525341310004000001000100d973bda91f7175
2c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a
519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e
10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c
886b3ee1

Public key token is c5687fc88969c44d


If you right click on the dll it'll also give you the version of the dll. The version and the public key token is needed for you to place in your web.config file.

So you're web.config file should look something like this:

          <membership defaultProvider="MySqlMembershipProvider" >
            <providers>
              <clear/>
              <add name="MySqlMembershipProvider"
                   type="MySql.Web.Security.MySQLMembershipProvider,                 
                   MySql.Web, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"

                   autogenerateschema="true"
                   connectionStringName="AdminConnString"
                   enablePasswordRetrieval="false"
                   enablePasswordReset="true"
                   requiresQuestionAndAnswer="false"
                   requiresUniqueEmail="false"
                   passwordFormat="Hashed"
                   maxInvalidPasswordAttempts="5"
                   minRequiredPasswordLength="6"
                   minRequiredNonalphanumericCharacters="0"
                   passwordAttemptWindow="10"
                   passwordStrengthRegularExpression=""
                   applicationName="/"
                   />
            </providers>
          </membership>

Notice in the add name carrot I reference the public key token and the version of the dll.

This right there pretty much helps you link up your asp.net application to use MySQL Membership Provider.

Check out the video below, it pretty much describes what I just said:
https://www.youtube.com/watch?v=NN4y_88vNvo

Shows how to link ASP.NET membership with MySQL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文