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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
明白了!使用 MySql Connector/Net 版本 6.2.2.0,请按照以下步骤操作。 ..
将 web.config 中的
更改为:Got it figured out! Using version 6.2.2.0 of MySql Connector/Net, follow these steps...
Change your
<membership>
in web.config to this:最初的问题没有指定 ASP.NET 和 ASP.NET 的版本。使用了MVC。随着最近发布的 .NET 4.5 和 MVC 4,我遇到了与 OP 相同的问题,但使用了新技术。这是我的 快速修复它 基本上与 Josh Stodola 的答案相同的配置,但有一些额外的步骤。
让 AccountController 和视图正常工作:
@Html.Partial(“_LogOnPartial”) 共享 _Layout 视图中的
@Html.Partial(“_LoginPartial”)
The original question didn't specify which version of ASP.NET & MVC was used. With the recent release of .NET 4.5 and MVC 4 I hit the same problem as the OP but with the new technologies. This is my quick fix for it mostly the same config as Josh Stodola's answer but with some additional steps.
Get the AccountController and Views working:
@Html.Partial(“_LoginPartial”)
in the shared _Layout view with@Html.Partial(“_LogOnPartial”)
我已经用asp.net做到了这一点,但我认为它也可以用于mvc: hasangursoy.com.tr/aspnet-authorization-authentication-with-mysql
I've did this with asp.net but I think it could be used for mvc too: hasangursoy.com.tr/aspnet-authorization-authentication-with-mysql
在我的场景中,我不需要从 .NET Web 应用程序连接到 MySQL。因此,我通过做两件事解决了这个问题:
1)卸载MySQL .NET Connector(所有版本)
2) 在Web.Config 文件中,删除MySQL 安装后添加的所有密钥。 (或者,将安装前的原始 Web.Config 文件复制回 .NET Web 应用程序根文件夹)
现在,我的 .NET 应用程序已恢复正常
In my scenario, I do not need to connect to MySQL from my .NET web applications. Therefore, I solved this problem by doing two things:
1) Uninstall MySQL .NET Connector (all versions)
2) Inside the Web.Config file, remove all keys that were added after the MySQL installation. (Or else, copy back the original Web.Config file before installation to the .NET web application root folder)
Now, my .NET application is bac
不得不经历类似的事情。
这是对我有帮助的官方 MySql 演练:
教程:MySQL 连接器/Net ASP.NET成员资格和角色提供者
注意:在我的例子中,要编辑的
machine.config
是 32 位 的(他们没有指定哪个,并且编辑64 位的没有帮助)。Had to go through something similar.
Here's the official MySql walkthrough that helped me:
Tutorial: MySQL Connector/Net ASP.NET Membership and Role Provider
Note: In my case, the
machine.config
to be edited was the 32 bit one (they didn't specify which, and editing the 64bit one didn't help).单击菜单“项目”,然后单击“ASP.NET 配置”。
这将在 Data 文件夹中为您创建 sql 数据库。
使用 Visual Studio 查看数据。
希望这有帮助。
编辑
我应该补充一点,您可以使用 Ctrl+Alt+S 查看服务器资源管理器,然后您应该可以看到数据库及其表和数据。
您不需要安装 SQL。
Click on the menu Project followed by ASP.NET Configuration.
That will create the sql database for you in the Data folder.
Use Visual Studio to look at the data.
Hope this helps.
Edit
I should add that you can then use Ctrl+Alt+S to see the Server Explorer which should then allow you to see your database with its tables and the data.
You shouldn't need SQL installed.