我试图让我的自定义“CREATEUSER”工作,但我认为我的 web.config 有问题。感谢这里的帮助,我已经编写了 MEMBERSHIP 部分,但是我的 MEMBERSHIP.CREATEUSER 命令无法登录到数据库。错误是“无法登录到默认数据库”。我添加了一个连接字符串,名称在我的部分中。但我被困住了。
Here is the code-behind file for creating the user:
protected void submit_Click(object sender, EventArgs e)
{
Membership.CreateUser(userName.Text, passwdConfirm.Text, email.Text);
}
而且,这是我的 Web.config 文件。
<configuration>
<connectionStrings>
<add name="FVTCEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=SFP;attachdbfilename=H:\ASP.Net\FVRG\FVRG\App_Data\FVTC.mdf;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="dbMembership" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=H:\ASP.Net\FVRG\FVRG\App_Data\ASPNETDB.MDF;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<authorization>
<allow roles="ADMIN" />
<allow roles="GUEST" />
</authorization>
<roleManager enabled="true" />
<authentication mode="Forms" />
<compilation debug="true" targetFramework="4.0" />
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="dbMembership"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="/FVRG" />
</providers>
</membership>
</system.web>
<appSettings>
<add key="DatabaseConnection" value="Data Source=.\SQLEXPRESS;AttachDbFilename=H:\ASP.Net\FVRG\FVRG\App_Data\FVTC.mdf;Integrated Security=True;User Instance=True" />
</appSettings>
</configuration>
在此先感谢您的帮助!