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

<tfoot id='WlYUi'></tfoot>

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

        如何使用 MySQL 设置 ASP.NET MVC 2?

        时间:2023-06-25
          1. <small id='Q3PJ9'></small><noframes id='Q3PJ9'>

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

                  <tbody id='Q3PJ9'></tbody>

                <tfoot id='Q3PJ9'></tfoot>
                  <bdo id='Q3PJ9'></bdo><ul id='Q3PJ9'></ul>
                  本文介绍了如何使用 MySQL 设置 ASP.NET MVC 2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以设置 ASP.NET MVC 2 以使用 MySQL 数据库?

                  Is it possible to setup ASP.NET MVC 2 to work with a MySQL database?

                  推荐答案

                  我假设您拥有 Visual Studio Professional 2008,可以访问 MySQL 服务器的实例,并且具有中到高级的开发经验.这可能适用于 VS2008 网络版,但完全不确定.

                  I'm assuming that you have Visual Studio Professional 2008, have access to an instance of MySQL server, and have moderate to advanced development experience. This MAY work with VS2008 Web edition, but not at all sure.

                  1. 如果您还没有安装 MySQL Connector for .NET (6.2.2.0 在撰写本文时)
                  2. 可选:安装 MySQL GUI 工具
                  3. 如果尚未安装,请安装 MVC 2 RTM,或者更好的是,使用 Microsoft 的 Web 平台安装程序.(更新:MVC 2 已经发布了一段时间)
                  4. 创建一个空的 MySQL 数据库.如果您不想使用 MySQL 根用户帐户(不安全)访问您的应用程序,请创建一个用户帐户并分配适当的权限(不在本文讨论范围内).
                  5. 在 Visual Studio 中创建一个新的 MVC 2 应用程序
                  6. 在 MVC 2 应用程序中,引用 MySql.Web.dll.它将位于您的 GAC 中,或者位于 MySQL 连接器安装程序放置它的文件夹中.
                  7. 修改 web.config 的连接字符串部分:

                  1. If you haven't, install MySQL Connector for .NET (6.2.2.0 at the time of this write-up)
                  2. Optional: install MySQL GUI Tools
                  3. If you haven't, install MVC 2 RTM, or better yet, use Microsoft's Web Platform Installer. (UPDATE: MVC 2 has now been released for quite some time)
                  4. Create an empty MySQL database. If you don't want to access your application with the MySQL root user account (insecure), create a user account and assign the appropriate privileges (outside the scope of this write-up).
                  5. Create a new MVC 2 application in Visual Studio
                  6. In the MVC 2 app, reference MySql.Web.dll. It will either be in your GAC, or in the folder that the MySQL Connector installer put it.
                  7. Modify the connection strings portion of your web.config:

                    <connectionStrings> 
                      <remove name="LocalMySqlServer"/> 
                      <add name="MySqlMembershipConnection"
                           connectionString="Data Source=[MySql server host name];
                                             userid=[user];
                                             password=[password];
                                             database=[database name];" 
                           providerName="MySql.Data.MySqlClient"/>
                    </connectionStrings>
                  

                  8.

                  修改 web.config 的成员资格部分:

                  Modify the membership portion of your 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"  
                             connectionStringName="MySqlMembershipConnection"  
                             enablePasswordRetrieval="false"  
                             enablePasswordReset="true"  
                             requiresQuestionAndAnswer="false"  
                             requiresUniqueEmail="true"  
                             passwordFormat="Hashed"  
                             maxInvalidPasswordAttempts="5"  
                             minRequiredPasswordLength="6"  
                             minRequiredNonalphanumericCharacters="0"  
                             passwordAttemptWindow="10"  
                             applicationName="/"  
                             autogenerateschema="true"/>  
                        </providers>  
                      </membership>  
                  

                  9.

                  修改 web.config 的角色管理器部分:

                  Modify the role manager portion of your web.config:

                    <roleManager enabled="true" defaultProvider="MySqlRoleProvider">  
                      <providers>  
                        <clear />  
                        <add connectionStringName="MySqlMembershipConnection"  
                             applicationName="/"  
                             name="MySqlRoleProvider"  
                             type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, 
                                   Version=6.2.2.0, Culture=neutral, 
                                   PublicKeyToken=c5687fc88969c44d"  
                             autogenerateschema="true"/>  
                      </providers>  
                    </roleManager>
                  

                  10.

                  修改 web.config 的配置文件部分:

                  Modify the profile portion of your web.config:

                    <profile>  
                      <providers>  
                        <clear/>  
                        <add type="MySql.Web.Security.MySQLProfileProvider, MySql.Web, 
                                   Version=6.2.2.0, Culture=neutral, 
                                   PublicKeyToken=c5687fc88969c44d"  
                             name="MySqlProfileProvider"  
                             applicationName="/"  
                             connectionStringName="MySqlMembershipConnection"  
                             autogenerateschema="true"/>  
                      </providers>  
                    </profile>
                  

                  此时,您应该能够运行应用程序并在浏览器中显示默认的 ASP.NET MVC 2 主页.但是,最好先运行 ASP.NET Web 配置工具(在 Visual Studio 顶部菜单中:项目 -> ASP.NET 配置).工具启动后,检查每个选项卡;没有错误 = 一切顺利.

                  At this point, you ought to be able to run the app and have the default ASP.NET MVC 2 home page come up in your browser. However, it may be a better idea to first run the ASP.NET Web configuration Tool (in Visual Studio top menus: Project -> ASP.NET Configuration). Once the tool launches, check out each of the tabs; no errors = all good.

                  Nathan Bridgewater 的博客 对实现这一目标至关重要.荣誉,内森.寻找页面中间的配置工具".

                  The configuration tool at Nathan Bridgewater's blog was essential to getting this working. Kudos, Nathan. Look for the "Configuration Tool" heading half way down the page.

                  我在这里发布的 MySql.web.dll 上的公钥令牌应该不会很快改变.但是,如果您怀疑通过复制和粘贴或其他方式产生了错误的令牌字符串,只需使用 Visual Studio 命令行运行:sn -T [Path\to\your.dll]"以获得正确的公钥令牌.

                  The public key token on the MySql.web.dll that I've posted here ought not change any time soon. But in case you suspect a bad token string from copying and pasting or whatever, just use the Visual Studio command line to run: "sn -T [Path\to\your.dll]" in order to get the correct public key token.

                  你知道了,ASP.NET MVC 2 在 MySQL 上运行.干杯!

                  There you have it, ASP.NET MVC 2 running over MySQL. Cheers!

                  这篇关于如何使用 MySQL 设置 ASP.NET MVC 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MySQL - 持久连接与连接池 下一篇:MySQL INNER JOIN 从第二个表中只选择一行

                  相关文章

                  1. <legend id='7VSPo'><style id='7VSPo'><dir id='7VSPo'><q id='7VSPo'></q></dir></style></legend>

                    <small id='7VSPo'></small><noframes id='7VSPo'>

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

                      <bdo id='7VSPo'></bdo><ul id='7VSPo'></ul>