首先,我的开发环境:使用Visual Studio Professional 2010的Win7笔记本电脑。IIS是不安装。ASP.NET MVC 2 - 尝试通过ASP.NET配置工具配置角色/用户管理
我试图通过ASP.NET配置工具打开并设置用户管理的某些角色,如MVCMusicStore教程中所演示的。当我点击'安全'选项卡时,出现以下错误:
“您选择的数据存储存在问题,这可能是由于服务器名称或凭证无效或者权限不足造成的。也可能是由于未启用角色管理器功能导致的,请单击下面的按钮将其重定向到可以选择新数据存储区的页面
以下消息可能有助于诊断问题:无法加载类型'HandiGamer.MvcApplication'“
当我点击'按钮下面',它告诉我我使用AspNetSqlProvider作为我的提供者。当我尝试测试它时,它告诉我:
“无法建立到数据库的连接。 如果尚未创建SQL Server数据库,请退出Web站点管理工具,请使用aspnet_regsql命令行实用程序来创建和配置数据库,然后返回到此工具来设置提供程序。“
事情是这样的:当我在调试器中运行
的MVCMusicStore演示的角色/用户管理工作。我可以添加自己作为客户,并添加/删除我的购物车中的物品。 尽管这个,当我尝试使用它的配置工具时,我得到了相同的错误。
我实际上已经在我的SQL Server 2008 Express副本上运行了aspnet_regsql。它为用户管理创建了必要的表格。仍然没有解决我的问题。
我只是想知道如果我失去了一些东西很明显,作为教程基本上说,“点击两个按钮和你所有的设置。”它从字面上没有说为此设置数据库。
我只是在这一点难住。角色/用户管理工作(MVCMusicStore证明它可以),但配置工具不会让我打开它,设置它,或者编辑它的工作方式。这变得非常令人沮丧。任何帮助将不胜感激。
编辑:我的web.config是如下 -
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="HandiGamer" connectionString="data source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|handigamer.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="HandiGamer" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="HandiGamer" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="HandiGamer" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="HandiGamer" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>