我正在尝试托管我的第一个 ASP.NET 项目,在通过 FTP 初始上传后,我得到了 SQL 连接错误,所以在进行了一些搜索后,我认为这是我的连接字符串,所以我通过正确放置我的主机信息来修复它:
<add name="orangefreshConnectionString1" connectionString="Data Source=<server>;Initial Catalog=<catalog>;User Id=<user>;Password=<pwd>;" providerName="System.Data.SqlClient" />
所以这解决了我的问题,我的网站现在已经启动......除了我尝试登录时,我得到另一个 SQL 连接错误。
我在我的网站上使用了 2 个数据库:dbstart 和 ASPNETDB(最后一个用于会员资格)
ASPNETDB 在我的开发 web.config 上被处理为:providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
我知道这里有一些需要更改的地方,但是到目前为止,我的谷歌查询对找到答案没有帮助......
这是我的开发 web.config 内容:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="orangefreshConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\orangefresh.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="orangefreshEntities" connectionString="metadata=res://*/App_Code.Orangefresh.csdl|res://*/App_Code.Orangefresh.ssdl|res://*/App_Code.Orangefresh.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\orangefresh.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<roleManager enabled="true" />
<authentication mode="Forms">
<forms loginUrl="default.aspx"></forms>
</authentication>
<pages theme="orangefresh" />
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
</compilation>
<httpRuntime requestValidationMode="2.0" />
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="João <email@email.com>">
<network host="host" userName="user" password="pass" />
</smtp>
</mailSettings>
</system.net>
<location path="Management">
<system.web>
<authorization>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
</configuration>
如何在 web.config 上正确引用我的会员数据库?