<?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="dbConnectionString"
connectionString="Data source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db.mdf;Integrated Security=True;User Instance=True"/>
</connectionStrings>
<system.web>
<compilation debug="true"/></system.web></configuration>
-------------------------------------------
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Configuration;
using System.Data.SqlClient;
public partial class Default : System.Web.UI.Page
{
protected void Login1_Authenticate(object sender,AuthenticateEventArgs e)
{
string UserName = Login1.UserName;
string Pwd = Login1.Password;
string strConn;
strConn = WebConfigurationManager.ConnectionStrings["dbConnectionString"].ConnectionString;
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
string sqlUserName;
sqlUserName = "SELECT UserName,Password FROM Members";
sqlUserName += " WHERE (UserName = @UserName";
sqlUserName += " AND Password = @Password)";
SqlCommand com = new SqlCommand(sqlUserName, Conn);
com.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = UserName;
com.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Pwd;
SqlDataReader dr = com.ExecuteReader();
if (dr.HasRows)
{
Session["UserAuthentication"] = UserName;
Session.Timeout = 1;
Response.Redirect("MembersOnly.aspx");
}
else
{
Session["UserAuthentication"] = "";
}
dr.Close();
}
}