请原谅我,如果我的问题是愚蠢的,或者就我编程的新手而言。这个堆栈溢流文章Visual Studio 2013 and ASP.NET Web Configuration Tool为我节省了运行Visual Studio 2013 WSA工具的时间,但我遇到了一个新问题,它是与SQL Server数据库的连接。
问题是,当我通过cmd运行IIS Express然后将地址放入浏览器时,我被重定向到WSA工具但是当我点击安全选项卡或链接时,我收到此错误:
您选择的数据存储存在问题。这可能是由无效的服务器名称或凭据或权限不足引起的。它也可能是由未启用角色管理器功能引起的。单击下面的按钮可重定向到可以选择新数据存储的页面。
以下消息可能有助于诊断问题:
无法连接到SQL Server数据库
我的连接字符串如下所示:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=.; Initial Catalog=aspnetdb; User Id=sa; Password=***********; Integrated Security=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
整个我的申请web.config
如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.; Initial Catalog=aspnetdb; User Id=sa; Password=***********; Integrated Security=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
我在我的MVC应用程序中看不到<rolemanager enabled=true>
,即使我尝试了一个具有此<rolemanager enabled="true">
但是甚至没有工作的Web应用程序。
你有什么建议?!
此致 Dostdar
答案 0 :(得分:1)
如果您打算以sa身份连接到SQL Server,请尝试从连接字符串中删除“Integrated Security = true”。
如果设置为true,则使用当前的Windows帐户凭据进行身份验证。您的Windows用户可能没有相应的数据库权限。
答案 1 :(得分:0)
我认为您需要转到sql server并在对象资源管理器中搜索安全性 - &gt; sa - &gt;状态 - &gt;登录 - &gt;启用
答案 2 :(得分:0)
查看下面的连接字符串,您指向一个本地完整的SQL Server安装实例,但是您真的有一个名为aspnetdb
的数据库吗?因为您在连接字符串Initial Catalog=aspnetdb;
中提到了这一点。
您尝试访问的aspnetdb
是一个ASP.NET身份数据库,我强烈怀疑它是App_Data
文件夹下的解决方案/项目中的附加数据库。在这种情况下,您的连接字符串是错误的(您应该指向localDB
而不是),因此您将面临错误。
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=.; Initial Catalog=aspnetdb; ...
providerName="System.Data.SqlClient" />
</connectionStrings>
答案 3 :(得分:0)
试试这个。
更改web.config
连接字符串
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=Your PC Name; Initial Catalog=aspnetdb; User Id=sa; Password=***********; " providerName="System.Data.SqlClient" />
</connectionStrings>
例如。数据源= XYZ\SQLEXPRESS
并尝试删除
Integrated Security=true