[英]Unable to connect to SQL Server database in ASP.NET Web Admin Tool
Like the title says I am trying to make some roles for a site that i am making. 就像标题所说的那样,我正在尝试为自己正在创建的网站扮演一些角色。
Whenever I enter the security tab the error in the title is displayed. 每当我进入安全选项卡时,就会显示标题中的错误。
I have used the aspnet_regsql wizard to configure a database for this purpose. 我已经使用aspnet_regsql向导为此配置数据库。 The creation of the database was successful , but i still get the error. 数据库创建成功 ,但是仍然出现错误。
Here is the webconfig so far: 到目前为止,这是webconfig :
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<entityFramework>
<contexts>
<context type="ContosoUniversity.DAL.SchoolContext, ContosoUniversity">
<databaseInitializer type="ContosoUniversity.DAL.SchoolInitializer, ContosoUniversity" />
</context>
</contexts>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="SchoolContext" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<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="TESTMVC" />
</namespaces>
</pages>
</system.web.webPages.razor>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>
I know I am probably missing some membership tag in this xml? 我知道我可能在此xml中缺少一些会员标签吗? Could anyone help me fix the webconfig file? 谁能帮我修复webconfig文件?
This connection string is used for a page that displays some stuff from this database. 此连接字符串用于显示该数据库中某些内容的页面。 On this save (localdb)\\MSSQLLocalDB i have the aspnetdb made by the wizard aspnet_regsql. 在此保存(localdb)\\ MSSQLLocalDB上,我具有由向导aspnet_regsql创建的aspnetdb。
<connectionStrings>
<add name="SchoolContext" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=ContosoUniversity1;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Base on your comment you are new to ASP.NET Membership. 根据您的评论,您是ASP.NET Membership的新手。 ASP.Net Membership you mentioned is over 10 to 15 years old. 您提到的ASP.Net成员已有10到15年的历史。 Microsoft has replaced it few others in those years. 微软在那几年取代了它。
Here is the history - 这是历史-
Since you are also new to ASP.Net Membership, I personally recommend to use ASP.Net Identity. 由于您也是ASP.Net成员身份的新手,因此我个人建议使用ASP.Net身份。 Here is the free ASP.NET MVC 5 Fundamentals course by Scott Allen 这是Scott Allen的免费ASP.NET MVC 5基础课程
With Integrated Security=SSPI
, I believe you are going to connect to SQL server as whatever account the web site is running under, likely an apppool identity account. 借助Integrated Security=SSPI
,我相信您将以网站正在运行的任何帐户(可能是apppool身份帐户)连接到SQL Server。 You should either create a user in SQL and explicitly connect with those credentials, or add the app pool identity to have permissions: 您应该使用SQL创建用户并使用这些凭据进行显式连接,或者添加应用程序池标识以具有权限:
For a local SQL Server (from https://blogs.msdn.microsoft.com/ericparvin/2015/04/14/how-to-add-the-applicationpoolidentity-to-a-sql-server-login/ ): 对于本地SQL Server(来自https://blogs.msdn.microsoft.com/ericparvin/2015/04/14/how-to-add-the-applicationpoolidentity-to-a-sql-server-login/ ):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.