Hello all, im trying to set up membership using a remote database, but I am having a few issues!
I have done this before using the asp.net login control and administration tool with no problems, but this is not so easy.
I am receiving this error when entering the asp.net administration tool (Asp.Net Configuration):
The following message may help in diagnosing the problem: Unrecognized configuration section membership. (C:\Users\ROB\Desktop\PROJECT - Copy\PaymentSystem\web.config line 13)
Which I think is - <add name="AspNetSqlMembershipProvider" - (web.config)
Do I need to include the AspNetSqlMembershipProvider class in my login.cs? Although my code works I am not sure if it is sufficient for what I am trying to do!!? :s
Any help will be gratefully received!
Login.aspx.cs
Code: Select all
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ButtonLogin_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["UserConnectionString"].ConnectionString);
con.Open();
string cmdStr = "SELECT COUNT(*) FROM UserTable WHERE EmailAddress= '" + TextBoxLoginEmail.Text + "'";
SqlCommand checkEmail = new SqlCommand(cmdStr, con);
int temp = Convert.ToInt32(checkEmail.ExecuteScalar().ToString());
if (temp == 1)
{
string cmdStr2 = "SELECT Password FROM UserTable WHERE EmailAddress= '" + TextBoxLoginEmail.Text + "'";
SqlCommand checkPword = new SqlCommand(cmdStr2, con);
string password = checkPword.ExecuteScalar().ToString();
con.Close();
if (password == TextBoxLoginPword.Text)
{
Session["New"] = TextBoxLoginEmail.Text;
Response.Redirect("Default.aspx");
}
else
{
LabelInvalidPword.Visible = true;
LabelInvalidPword.Text = "Password Not Recognised...!";
}
}
else
{
LabelInvalidEmail.Visible = true;
LabelInvalidEmail.Text = "Email Not Recognised...!";
}
}
}
Code: Select all
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="UserConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\UserDatabase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="UserBankDatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\UserBankDatabase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="TheBankDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\ROB\Desktop\PROJECT\ExternalBank\App_Data\TheBankDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="MerchantBankDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\ROB\Desktop\PROJECT\MerchantBank\App_Data\MerchantBankDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="UserConnectionString"
passwordFormat="Encrypted"
enablePasswordRetrieval="true"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
maxInvalidPasswordAttempts="10"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="30"
applicationName="/"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="UserConnectionString" applicationName="/"/>
</providers>
</roleManager>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<appSettings>
<add key="BankHost.BankService" value="http://localhost:50743/ExternalBank/BankService.asmx"/>
</appSettings>
</configuration>