0

首先,我的开发环境:装有 Visual Studio Professional 2010 的 Win7 笔记本电脑。未安装IIS 。

我正在尝试通过 ASP.NET 配置工具打开并设置一些用户管理角色,如 MVCMusicStore 教程中所示。当我单击“安全”选项卡时,出现以下错误:

“您选择的数据存储存在问题。这可能是由于服务器名称或凭据无效,或权限不足造成的。也可能是未启用角色管理器功能。单击下面的按钮重定向到您可以在其中选择新数据存储的页面。

以下消息可能有助于诊断问题:无法加载类型“HandiGamer.MvcApplication”。"

当我单击“下面的按钮”时,它告诉我我正在使用 AspNetSqlProvider 作为我的提供程序。当我尝试测试它时,它告诉我:

“无法建立与数据库的连接。如果尚未创建 SQL Server 数据库,请退出网站管理工具,使用 aspnet_regsql 命令行实用程序创建和配置数据库,然后返回此工具进行设置提供者。”

事情是这样的:

  1. 当我通过调试器运行 MVCMusicStore 演示时,它的角色/用户管理工作。我可以将自己添加为客户,并从我的购物车中添加/删除商品。 尽管如此,当我尝试使用配置工具时,我得到了同样的错误。

  2. 我实际上已经在我的 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>
4

1 回答 1

0

找到了解决方案。必须在配置工具“看到”数据库安全内容之前编译/构建我的解决方案。

于 2010-08-27T23:35:01.733 回答