【发布时间】:2014-07-20 19:34:33
【问题描述】:
我创建了一个网站。在 Appdata 文件夹中,我创建了一个数据库 (info.mdf)。
我将它连接到 SQLEXpress
我已在 SQL mngmnt studio 中为可用用户添加了 NETWORK SERVICE。我去了用户映射并添加了我的数据库。我选择了 db_owner、public 和 aspnet_Membership_FullAccess。我使用本地用户名执行了相同的过程,但我猜由于我设置数据库的方式,本地用户在实际数据库中的用户下显示为 dbo。
我将 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=169433
-->
<configuration>
<connectionStrings>
<add name="MembershipConnection" connectionString="Server=machinename\SQLEXPRESS; Initial Catalog=Info;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="1720">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MembershipConnection"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="10"
passwordAttemptWindow="30"
minRequiredPasswordLength="3"
minRequiredNonalphanumericCharacters="0"
applicationName="/" />
</providers>
</membership>
<roleManager enabled ="true" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我还在连接字符串中尝试了 Trusted_Connection=Yes 以及 Integrated Security=SSPI
我得到的错误是:
[SqlException (0x80131904): 无法打开登录请求的数据库“信息”。登录失败。 用户 'MachineName\username' 登录失败。]
想法?
【问题讨论】:
标签: c# asp.net sql visual-studio-2010 forms-authentication