First you have to design a login form:
username:
password:
login:
Coding like this
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication.css.WebForm1" >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
username<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
password<asp:TextBox ID="TextBox2" runat="server" style="margin-bottom: 0px"></asp:TextBox>
</div>
<p>
<asp:LoginStatus ID="loginsuccessfully" runat="server" />
</p>
<p>
</p>
<p>
</p>
</form>
</body>
</html>Next page coding this:<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm3.aspx.vb" Inherits="WebApplication.css.WebForm3" >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
welcome soundaryaharee<br />
</div>
</form>
</body>
</html>Login coding for VB: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.Configuration;
using System.Data.SqlClient;
using System.Web.Security;
namespace User_Login_CS
{
public partial class Login : System.Web.UI.Page
{
protected void ValidateUser(object sender, EventArgs e)
{
int userId = 0;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Validate_User"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Username", Login1.UserName);
cmd.Parameters.AddWithValue("@Password", Login1.Password);
cmd.Connection = con;
con.Open();
userId = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
switch (userId)
{
case -1:
Login1.FailureText = "Username and/or password is incorrect.";
break;
case -2:
Login1.FailureText = "Account has not been activated.";
break;
case -3:
Response.Write("welcome soundaryaharee");
break;
}
}
}
}Web confiquration:<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="constr" connectionString="Data Source=edpadmin-
pc\test.Trainee.dbo;Initial Catalog=LoginDB;user id=sa;password=SA;"/>
</connectionStrings>
<compilation debug="true" targetFramework="4.0"/>
<system.web>
<authentication mode="Forms">
<forms defaultUrl="~/Home.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880">
</forms>
</authentication>
</system.web>
</configuration>