Database 连接到ASP.NET成员资格服务数据库时出现问题

Database 连接到ASP.NET成员资格服务数据库时出现问题,database,authentication,asp.net-membership,connection,database-connection,Database,Authentication,Asp.net Membership,Connection,Database Connection,我一直在对使用ASP.NET会员服务数据库进行身份验证的应用程序进行一些更改 我可以使用windows身份验证和SA用户在本地访问数据库 但是,在将应用程序移动到prod.server之后,我根本无法访问数据库 我编写了一个简单的测试应用程序来测试我的conn字符串 AuthenticationConnectionString失败。 AppDBConnString成功连接 <add connectionString="Server=****\**;Database=FNAuthentica

我一直在对使用ASP.NET会员服务数据库进行身份验证的应用程序进行一些更改

我可以使用windows身份验证和SA用户在本地访问数据库

但是,在将应用程序移动到prod.server之后,我根本无法访问数据库

我编写了一个简单的测试应用程序来测试我的conn字符串

AuthenticationConnectionString失败。 AppDBConnString成功连接

<add connectionString="Server=****\**;Database=FNAuthentication;User ID=***;Password=***" name="AuthenticationConnectionString" />
<add connectionString="Server=****\**;Database=AppDB;User ID=***;Password=***" name="AppDBConnString" />
我可以使用我在conn字符串中使用的同一用户登录ManagementStudio,可以打开这两个数据库并成功执行查询

<add connectionString="Server=****\**;Database=FNAuthentication;User ID=***;Password=***" name="AuthenticationConnectionString" />
<add connectionString="Server=****\**;Database=AppDB;User ID=***;Password=***" name="AppDBConnString" />
错误消息使我认为数据库的权限有问题,但我不知道需要更改什么

我们尝试启用所有角色,但没有成功

非常感谢您的帮助

问候


Francis

我认为您应该检查web.config中的成员资格提供程序和角色管理器提供程序,并将其设置为连接字符串

<membership defaultProvider="MyMembershipProvider" userIsOnlineTimeWindow="30">
        <providers>
            <add connectionStringName="MyConnectionString" applicationName="MyApp" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" passwordAttemptWindow="5" minRequiredNonalphanumericCharacters="0" minRequiredPasswordLength="5" passwordFormat="Clear" name="MyMembershipProvider" type="DBIndependent.Providers.SqlMembershipProvider"/>
        </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="MyRoleProvider">
        <providers>
            <add connectionStringName="MyConnectionString" applicationName="MyApp" name="MyRoleProvider" type="DBIndependent.Providers.SqlRoleProvider"/>
        </providers>
    </roleManager>

谢谢

已为membership和roleManager设置了connectionstring

<membership defaultProvider="ASPSqlMembershipProvider" userIsOnlineTimeWindow="15">
            <providers>
                <remove name="AspNetSqlMembershipProvider" />
                <add name="ASPSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="AuthenticationConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression="" />
            </providers>
        </membership>
        <roleManager defaultProvider="ASPSqlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPXROLES" cookiePath="/" cookieTimeout="30" cookieRequireSSL="false" cookieSlidingExpiration="true" createPersistentCookie="false" cookieProtection="All">
            <providers>
                <remove name="AspNetSqlRoleProvider" />
                <remove name="AspNetWindowsTokenRoleProvider" />
                <add connectionStringName="AuthenticationConnectionString" applicationName="/" name="ASPSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            </providers>
        </roleManager> 

我的问题是我根本无法登录数据库

我编写了以下测试应用程序来测试连接:

namespace TestConnStrings
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (SqlConnection testConn0 = new SqlConnection())
            {
                testConn0.ConnectionString = ConfigurationManager.ConnectionStrings["AuthenticationConnectionString"].ConnectionString;
                try
                {
                    testConn0.Open();
                }
                catch(Exception ex)
                {
                    Response.Write(ex.ToString());
                }

                if (testConn0.State == System.Data.ConnectionState.Open)
                {
                    Response.Write("AuthenticationConnectionString works");
                    testConn0.Close();
                }   
            }
            Response.Write("<br /><br /><br /><br /><br />");
            using (SqlConnection testConn1 = new SqlConnection())
            {
                testConn1.ConnectionString = ConfigurationManager.ConnectionStrings["AppDBConnString"].ConnectionString;
                try
                {
                    testConn1.Open();
                }
                catch (Exception ex)
                {
                    Response.Write(ex.ToString());
                }

                if (testConn1.State == System.Data.ConnectionState.Open)
                {
                    Response.Write("AppDBConnString works");
                    testConn1.Close();
                }
            }
        }
    }
}
名称空间测试字符串
{
公共部分类\u默认值:System.Web.UI.Page
{
受保护的无效页面加载(对象发送方、事件参数e)
{
使用(SqlConnection testConn0=newsqlconnection())
{
testConn0.ConnectionString=ConfigurationManager.ConnectionString[“AuthenticationConnectionString”]。ConnectionString;
尝试
{
testConn0.Open();
}
捕获(例外情况除外)
{
Response.Write(例如ToString());
}
if(testConn0.State==System.Data.ConnectionState.Open)
{
Write(“AuthenticationConnectionString工作”);
testConn0.Close();
}   
}
回答。写(“





”; 使用(SqlConnection testConn1=newsqlconnection()) { testConn1.ConnectionString=ConfigurationManager.ConnectionString[“AppDBConnString”].ConnectionString; 尝试 { testConn1.Open(); } 捕获(例外情况除外) { Response.Write(例如ToString()); } if(testConn1.State==System.Data.ConnectionState.Open) { Write(“AppDBConnString有效”); testConn1.Close(); } } } } }
AppDBConnString成功连接,AuthenticationConnectionString未成功连接

问候

弗朗西斯:)