Arvixe与MYSQL数据库共享托管,表单身份验证错误

时间:2012-05-15 18:20:31

标签: mysql asp.net-mvc shared-hosting form-authentication

我拥有我的实时数据库中存在的所有表单身份验证数据库表的完整副本,我可以看到数据存在,我可以在我的应用程序上连接和查看单独的数据...但是当我尝试登录时我的网站我得到了

建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)

然后潜在的错误似乎是它正在尝试创建一组新的用户身份验证表,因为它无法连接到我的MYSQL数据库。我这样说是由于堆栈跟踪错误:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5103182
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +260
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +389
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject, Boolean withFailover) +197
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +963
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +316
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +5119675
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +31
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +76
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.SqlClient.SqlConnection.Open() +125
   System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +82

**[HttpException (0x80004005): Unable to connect to SQL Server database.]**
   System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +137
   System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +94
   System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +27
   System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +395

我的Web.config文件看起来像

<remove name="LocalMySqlServer" />


<add name="mydbEntities" connectionString="metadata=res://*/DataEntity.csdl|res://*/DataEntity.ssdl|res://*/DataEntity.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=servername;User Id=id;password=password;Persist Security Info=True;database=mydb&quot;" providerName="System.Data.EntityClient" />
<add name="MySqlMembershipConnection" connectionString="server=localhost; user id=id; password=password; persist security info=true; database=mydb;" providerName="MySql.Data.MySqlClient"/>

<roleManager enabled="true" />
<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear />
    <add name="MySqlMembershipProvider" 
         type="MySql.Web.Security.MySQLMembershipProvider, 
         MySql.Web, 
         Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" 
         autogenerateschema="true" 
         connectionStringName="MySqlMembershipConnection" 
         enablePasswordRetrieval="false" 
         enablePasswordReset="true" 
         requiresQuestionAndAnswer="false" 
         requiresUniqueEmail="false" 
         passwordFormat="Hashed" 
         maxInvalidPasswordAttempts="5" 
         minRequiredPasswordLength="6" 
         minRequiredNonalphanumericCharacters="0" 
         passwordAttemptWindow="10" 
         passwordStrengthRegularExpression="" 
         applicationName="/" />
  </providers>
</membership>

我不确定为什么找不到我的MYSQL数据库或导致登录过程失败的事件链。

1 个答案:

答案 0 :(得分:1)

这个问题归结为我没有指定完整的成员资格,配置文件和roleManager选项。一旦我填写了这些并将我的应用程序指向我的MySQL数据库,它就停止尝试创建它自己的数据库来处理这些功能。下面是我的web.config文件需要包含的3个部分的示例...希望这可以节省其他人的挫折感,我得说Arvxie支持在这个问题上没有帮助。

<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear />
    <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" autogenerateschema="false" connectionStringName="MySqlMembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
  </providers>
</membership>
<profile>
  <providers>
    <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="MySqlMembershipConnection" applicationName="/" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="MySQLRoleProvider">
  <providers>
    <add connectionStringName="MySqlMembershipConnection" applicationName="/" name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  </providers>
</roleManager>