首先,我的開發環境:使用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>