ASP.Net服务器迁移本地生存

时间:2013-03-19 00:32:07

标签: c# asp.net sql asp.net-mvc database-connection

准备好将我的网站迁移到现场Godaddy服务器时,除了尝试登录时,一切都会进行计划。我得到以下错误。我的问题可能在于我的Web配置设置,但连接字符串连接到数据库正常。问题是我的网站仍然依赖本地服务器而不是远程服务器。

给出错误:

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配置:

               

 <!--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>

                                                 

1 个答案:

答案 0 :(得分:2)

您的会员资格,角色和资料提供程序都设置为使用您的SQL Express Attached数据库,而不是GoDaddy。改变它,它会工作。

我建议而不是重命名你的连接字符串,只是给它们两个相同的名字,然后注释掉(使用<!-- -->)你不想要的那个,这样你就不需要手动更新你的角色/ membership /配置文件配置。