Klinetel
Klinetel

Reputation: 302

ASP.Net Server Migration Local to Live

When ready to migrate my site to a live Godaddy server, everything goes to plan except when trying to login. I get the below error. My issue is probably within the way I have my web config setup, but the connection string connects to the database fine. The problem is my site still relies on the local server and not the remote one.

Error given:

Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'.


Stack Trace: 


[ArgumentException: Invalid value for key 'attachdbfilename'.]
System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean        enforceLocalHost, Boolean fixup) +907262
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +4116
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150
System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +4
System.Web.Providers.ModelHelper.CreateEntityConnection(ConnectionStringSettings setting,      String csdl, String ssdl, String msl) +90
System.Web.Providers.ModelHelper.CreateMembershipEntities(ConnectionStringSettings setting) +28
System.Web.Providers.DefaultMembershipProvider.GetPasswordWithFormat(String userName,  Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& format, String&  salt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean&  isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +123
System.Web.Providers.DefaultMembershipProvider.CheckPassword(String userName, String password, Boolean updateLastActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +96
 System.Web.Providers.DefaultMembershipProvider.ValidateUser(String username, String  password) +105
 System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +129
System.Web.UI.WebControls.Login.AttemptLogin() +127
 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean   includeStagesAfterAsyncPoint) +5563

Web Config:

 <!--Godaddy connection string used for live server-->

<add name="GoDaddy" connectionString=" Server=***; Database=***; User ID=****; Password=***; Trusted_Connection=False" providerName="System.Data.SqlClient" />



<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Kappa Lambda-20130125180802;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Kappa Lambda-20130125180802.mdf"
  providerName="System.Data.SqlClient" />

</authentication>

<profile defaultProvider="DefaultProfileProvider">
  <providers>
    <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
  <providers>
    <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
  <providers>
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</roleManager>



<!--
        If you are deploying to a cloud environment that has multiple web server instances,
        you should change session state mode from "InProc" to "Custom". In addition,
        change the connection string named "DefaultConnection" to connect to an instance
        of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
   -->
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
  </providers>
</sessionState>

Upvotes: 0

Views: 447

Answers (1)

Dai
Dai

Reputation: 155035

Your membership, role, and profile providers are all set to use your SQL Express Attached database, not GoDaddy's. Change it and it'll work.

I suggest rather than renaming your connection strings, to just give both the same name and then comment out (using <!-- -->) the one you don't want, so you don't need to manually update your role/membership/profile configuration.

Upvotes: 2

Related Questions