• Our Services
  • Press Releases
  • Explore Us
  • Login
  • Our WordPress Plugin
  • Blog Posting Services
  • In LinkedIn
  • Our Code Repository
  • In Twitter
J
HARAPHULA
OneStop Shop of Information

Updates

  • b2b Email Marketing jobs and ZOHO Campaigns for professionals
    •
  • YouTube Marketing Techniques to minimize Advertising Costs
    •
  • Increase your Video Views with Cutting-Edge YouTube Marketing Services
    •
  • 5 benefits of Online Reputation Management for your Brand
    •
  • How to Design an E-Commerce Website that Converts Visitors into Buyers?
    •
  • Is Whatsapp Marketing effective for Online Learning Platforms?
    •
  • 5 Mobile Marketing Trends to Reach Audience in a Mobile-First World
    •
  • How to Optimize PPC Campaigns for the Education Sector in India?
    •
  • Boost your ROI with Performance Marketing Techniques
    •
  • Your Complete Guide for hiring a Digital Marketing Agency
    •

ASP.NET Login page example with Remember me Option

Microsoft Technologies
May 15, 2016
3.7 (3 votes)
ASP.NET Login page example with Remember me Option ASP.NET Login page example with Remember me Option
5 5 82
On-page friendly Sidebar Widgets WordPress Plugin

During we develop a product its always wise to save user time. Think about a login page. Here for Consecutive logins it is much better if we will store user Login Credentials. Using which System will remember the user id and password for next login. In this demo app I am creating a ASP.NET login page with “Remember me” Option.

The logic behind is so simple “During a user login to the System I am storing his/her user id and password to a Cookie. Then under page load event checking is Cookie exists. If so taking user id and password from the Cookie”.

Login.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Demo Login App</title>
<style type="text/css">
#frmLogin { max-width: 300px; margin: 0 auto; padding-top: 120px; }
.formControl { font-family: Verdana; font-size: 12px; }
.loginDiv { width:300px; margin-top: 20px; padding: 20px 20px 20px 20px; background-color: #f7f7f7; -moz-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3); -webkit-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3); box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3); } 
.rounded { border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; }
</style>
</head>
<body>
<form id="frmLogin" runat="server">
<div class="loginDiv rounded">
<div class="formControl">
Email ID&nbsp;<span style="color: Red;">*</span>
</div>
<div class="formControl">
<asp:TextBox ID="txtEmailID" runat="server" Width="100%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmailID" runat="server" ControlToValidate="txtEmailID"
Display="Dynamic" ErrorMessage="Email should not be blank.<br />"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmailID" runat="server" ControlToValidate="txtEmailID"
Display="Dynamic" ErrorMessage="Enter a valid Email ID.<br />" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
<div class="formControl">
Password&nbsp;<span style="color: Red;">*</span>
</div>
<div class="formControl">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="100%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Password should not be blank."></asp:RequiredFieldValidator>
</div>
<asp:Button ID="btnVisitorLogin" runat="server" Text="Login" />
<asp:Label ID="lblMsg" runat="server"></asp:Label>
<asp:CheckBox ID="chkNextLogin" runat="server" />&nbsp;Remember me<a href="#" class="pull-right margin-gap">Need
help?</a>
</div>
</form>
</body>
</html>

For security reason in Code behind I added my EncryDecry.vb Class from app_code/vb. To execute vb code inside vb folder of app_code I Configured my web.config.

Login.aspx.vb

Imports System.Web.Security
Imports System.Data
Imports System.Data.SqlClient

Partial Class Login
Inherits System.Web.UI.Page

Dim LoginSqlConn As New SqlConnection(ConfigurationManager.AppSettings.Get("DBKey").ToString())

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
txtEmailID.Focus()

'Check if the browser support cookies
If Request.Browser.Cookies Then
'Check if the cookies with name PBLOGIN exist on user's machine
If Request.Cookies("PBLOGIN") IsNot Nothing Then
'Pass the user name and password to the VerifyLogin method
Me.VerifyLogin(Request.Cookies("PBLOGIN")("UNAME").ToString(), Request.Cookies("PBLOGIN")("UPASS").ToString())
End If
End If
End If
End Sub

Protected Sub btnVisitorLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnVisitorLogin.Click
'Decrypt the Password & UserID from Database
Dim EncrDecr As New EncryDecry

'Validation Checking Aginest Submission
If rfvPassword.IsValid And rfvEmailID.IsValid Then
'Clear Invalid login Message Label
lblMsg.Text = ""

'Temporary SecuredUniqueKey
Dim UniKey As String = "FCPH6-BPK27-2V4MR"

'Login Checking command in shape of a Stored Procedure that returns Record Count
Dim LoginCommand As New SqlCommand("USP_LoginCheck", LoginSqlConn)
LoginCommand.CommandType = CommandType.StoredProcedure

'Pass Parameter to Stored Procedure
LoginCommand.Parameters.Add("@UserID", SqlDbType.NVarChar, 256).Value = EncrDecr.TripleDESEncode(Trim(txtEmailID.Text), "RC2")
LoginCommand.Parameters.Add("@Passcode", SqlDbType.NVarChar, 256).Value = EncrDecr.TripleDESEncode(Trim(txtPassword.Text), "RC2")
LoginCommand.Parameters.Add("@SecuredUniqueKey", SqlDbType.NVarChar, 256).Value = UniKey
LoginCommand.Parameters.Add("@Status", SqlDbType.NVarChar, 20).Value = "Active"

Dim RecordCNT As Integer = 0

Try
Dim LoginDataReader As SqlDataReader
LoginSqlConn.Open()
LoginDataReader = LoginCommand.ExecuteReader
If LoginDataReader.Read Then
RecordCNT = Convert.ToInt32(LoginDataReader(0).ToString())
End If
Catch ex As Exception
Response.Write(ex.ToString())
Finally
LoginSqlConn.Close()
End Try

'Login Checking using the return int value of USP_LoginCheck stored procedure
If (RecordCNT = 1) Then
Me.VerifyLogin(EncrDecr.TripleDESEncode(Trim(txtEmailID.Text), "RC2"), EncrDecr.TripleDESEncode(Trim(txtPassword.Text), "RC2"))
ElseIf (RecordCNT > 1) Then
lblMsg.Text = "Invalid Login Credentials"
'Implement 5 Login Attempts of Account Lock
ElseIf (RecordCNT < 1) Then
lblMsg.Text = "Invalid Login Credentials"
'Implement 5 Login Attempts of Account Lock
End If
End If
End Sub

Private Sub VerifyLogin(ByVal UserID As String, ByVal Password As String)
Dim LoginDetailsCommand As New SqlCommand("USP_LoginDetails", LoginSqlConn)
LoginDetailsCommand.CommandType = CommandType.StoredProcedure

'Pass Parameter to Stored Procedure
LoginDetailsCommand.Parameters.Add("@UserID", SqlDbType.NVarChar, 256).Value = UserID
LoginDetailsCommand.Parameters.Add("@Passcode", SqlDbType.NVarChar, 256).Value = Password

Try
Dim LoginDetailsDR As SqlDataReader
LoginSqlConn.Open()
LoginDetailsDR = LoginDetailsCommand.ExecuteReader

If LoginDetailsDR.Read Then
Session("UserID") = LoginDetailsDR("PkUid")
Session("UserEmail") = UserID

Session("FirstName") = LoginDetailsDR("FirstName")
Session("LastName") = LoginDetailsDR("LastName")

Session("RootPath") = Server.MapPath("../")

'Using form authentication redirect the page to the Default.aspx
FormsAuthentication.RedirectFromLoginPage(Trim(txtEmailID.Text), True)

'check if remember me checkbox is checked on login
If (chkNextLogin.Checked) Then
'Check if the browser support cookies
If (Request.Browser.Cookies) Then
'Check if the cookie with name PBLOGIN exist on user's machine
If (Request.Cookies("PBLOGIN") Is Nothing) Then
'Create a cookie with expiry of 30 days
Response.Cookies("PBLOGIN").Expires = DateTime.Now.AddDays(30)
'Write username to the cookie
Response.Cookies("PBLOGIN").Item("UNAME") = UserID
'Write password to the cookie
Response.Cookies("PBLOGIN").Item("UPASS") = Password
Else
'If the cookie already exist then wirte the user name and password on the cookie
Response.Cookies("PBLOGIN").Item("UNAME") = UserID
Response.Cookies("PBLOGIN").Item("UPASS") = Password
End If
End If
End If
Else
lblMsg.Text = "Invalid Login Credentials"
End If
Catch ex As Exception
Response.Write(ex.ToString())
Finally
LoginSqlConn.Close()
End Try
End Sub
End Class

web.config

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="DBKey" value="Data Source=VIJAYSHANTI; uid=sa; pwd=tiger; database=CodeRND;"/>
</appSettings>
<connectionStrings/>
<system.web>
<compilation debug="true" strict="false" explicit="true">
<codeSubDirectories>
<add directoryName="VB"/>
</codeSubDirectories>
</compilation>
<authentication mode="Windows"/>
</system.web>
</configuration>

EncryDecry is the class which helps to convert user id and password to RC2 format. In-case an other user find out the cookie in client machine he or she can’t able to hack the original user.

EncryDecry.vb

Imports System.Security.Cryptography
Imports Microsoft.VisualBasic

Public Class EncryDecry

Public Function TripleDESEncode(ByVal value As String, ByVal key As String) As String
Dim des As New System.Security.Cryptography.TripleDESCryptoServiceProvider
des.IV = New Byte(7) {}
Dim pdb As New System.Security.Cryptography.PasswordDeriveBytes(key, New Byte(-1) {})
des.Key = pdb.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})
Dim ms As New IO.MemoryStream((value.Length * 2) - 1)
Dim encStream As New System.Security.Cryptography.CryptoStream(ms, des.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write)
Dim plainBytes As Byte() = Text.Encoding.UTF8.GetBytes(value)
encStream.Write(plainBytes, 0, plainBytes.Length)
encStream.FlushFinalBlock()
Dim encryptedBytes(CInt(ms.Length - 1)) As Byte
ms.Position = 0
ms.Read(encryptedBytes, 0, CInt(ms.Length))
encStream.Close()
Return Convert.ToBase64String(encryptedBytes)
End Function

Public Function TripleDESDecode(ByVal value As String, ByVal key As String) As String
Dim des As New System.Security.Cryptography.TripleDESCryptoServiceProvider
des.IV = New Byte(7) {}
Dim pdb As New System.Security.Cryptography.PasswordDeriveBytes(key, New Byte(-1) {})
des.Key = pdb.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})
Dim encryptedBytes As Byte() = Convert.FromBase64String(value)
Dim ms As New IO.MemoryStream(value.Length)
Dim decStream As New System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write)
decStream.Write(encryptedBytes, 0, encryptedBytes.Length)
decStream.FlushFinalBlock()
Dim plainBytes(CInt(ms.Length - 1)) As Byte
ms.Position = 0
ms.Read(plainBytes, 0, CInt(ms.Length))
decStream.Close()
Return Text.Encoding.UTF8.GetString(plainBytes)
End Function

End Class

Tags:ASP.NET Login Page, Cleaver UI developer, Login page Example, Remember me Option, Windows Authentication
Simple string to image based free PHP Captcha Code
Simple PHP pagination Example using MySQL records

Related Posts

  • Microsoft ASP.NET Interview Questions with Answers
  • Create, Remove or Read a PHP Cookie using Setcookie method
  • How to Make a Mobile App? - Full Guide for 2025
  • Top Searched popular Sexy & Hot South Indian Actresses
  • ASP.NET Login form Example validating user from SQL…
  • The Timeless Elegance of Janhvi Kapoor in Sarees
  • Horoscope Sign Aries Man Personality & Characteristics
  • How to update records in a Gridview using Auto…
  • How to implement Paging and Sorting in ASP.NET…
  • How to display various Files icon images in Datagrid rows?
  • Hot & Awaiting Bollywood Actress Sonakshi Sinha photo Stills
  • Katrina Kaif top rated hot Photos and Bollywood Movies
  • Guide to eCommerce App Development - Benefits, Cost,…
  • Example of Resume for IT professionals to get their…
  • Custom Cookie Boxes - Premium Packaging for Cookies
  • How Can I See My Husband's WhatsApp Messages without…
  • Popular Cine South Actress Shruti Hassan hot HD Photos
  • How to implement Forms Authentication in ASP.NET?
  • Salesforce Mobile App Development - Revolutionizing…
  • Interesting Short Junior KG Stories for Jr Kg Students
  • How to make a Simple Iphone App and upload it in the…
  • How to Check is Browser Cookie enabled or disabled…
  • How to Display Short and Long Product Descriptions…
  • Top Mobile App Development Trends in 2025 - How…
  • How does Product Engineering bring Technology to Life?
  • In relationship how to deal with a breakup? - Tips for Men
  • Step-by-Step Guide to resetting Windows 7 password
  • Kareena Kapoor biography, DOB, Filmography, latest…
  • How to use JavaScript function with ASP.NET CustomValidator?
  • How to display Excel File records in an ASP.NET Gridview?

Popular Categories

  • Miscellaneous589
  • Digitalization298
  • Career Guide244
  • Indian Blog211
  • Business Book179
  • Health & Wellness168
  • Travel & Tourism132
  • Your Financial Advisor120
  • Real Estate Consulting111
  • Shopping97
  • Blogging Techniques78
  • Home Remedies70
  • SEO Techniques68
  • Programming62
  • Digital Marketing61
  • Automobiles57
  • Fashion & Fantacy53
  • Easy Recipes52

Our Popular Links

BootStrap Dropdown list with Checkbox Selected values will Show
Cheapest Cloud Hosting Services for Node.js Applications
How to keep Mashed Potatoes Warm all Dinner Long?
List of Linux Website Hosting Companies
Cheapest Hosting Plans for Joomla Blogs
Linux, PHP, MySQL Hosting Solutions for Freelancers
Hosting Plans for Large Enterprise Websites
Vitamin K Is the Solution Said to Fade Dark Circles
Hosting Limitations for Shared Servers
Why I will Choose VPS Hosting for Game Applications?
SSD Storage Hosting Services with High-Speed MySQL Servers

Our Web2 Blogs

Home Remedies
SEO Guest Posting
Digital Marketing
Learn Digital Marketing
Blog Posting Services
Blog for Bloggers
SEO Blog
Blog for Tourism

i20 Sidebar Widgets

Best Tips on Taking your Baby out for the First Time
Best Tips on Taking your Baby out for the First Time
Taking your Baby out. If you are reading this article and have reached here through a search, I am pretty sure that you are just...
Classroom Atmosphere to Safety provisions the essentials of a Play School
Classroom Atmosphere to Safety provisions the essentials of a Play School
A play school business has many intricacies involved. The benefits of play schools to kids are what make them popular with parents. Most parents want...
Wооdеn Blосkѕ to Waboba Pro Bаlls Fun Toys for your Kids
Wооdеn Blосkѕ to Waboba Pro Bаlls Fun Toys for your Kids
Mауbе, instead, уоu wоndеr if уоu саn find something that’s a bit cheaper but оf рrасtiсаllу the same quality. Yоu can dо bоth, actually, bу...
5 Reasons Why Outdoor Play is essential for Kids
5 Reasons Why Outdoor Play is essential for Kids
It’s no secret that outdoor play benefits kids of all ages. From providing physical activity to connecting with nature, the importance of outdoor play for children...
5 Things to Consider When buying Wooden Toys
5 Things to Consider When buying Wooden Toys for Children
Many of us have fond memories of buying our first wooden toy as children. Whether it was a rocking horse, a castle or an elephant,...
Zoo or Pаrk popular Places tо Hоѕt уоur Kidѕ Birthday Pаrtiеѕ
Zoo or Pаrk popular Places tо Hоѕt уоur Kidѕ Birthday Pаrtiеѕ
Is your сhild having a birthday раrtу? Thiѕ article can help with your раrtу planning. If уоur hоuѕе is nоt suited fоr аn аt-hоmе party,...
Diaper Change to Vaseline 10 Baby Circumcision after Care ideas
Diaper Change to Vaseline 10 Baby Circumcision after Care ideas
Circumcision refers to a standard procedure where the foreskin at the penis tip is removed surgically. Circumcision is usually done on a newborn boy within...
Why Online Preschool Courses are beneficial for Children?
Why Online Preschool Courses are beneficial for Children?
For parents who cannot find the time or money to send their child to an in-person preschool, online courses can be a great option. These...
Tips for keeping your Children Safe as they Grow Older
Tips for keeping your Children Safe as they Grow Older
As parents, it is up to us to guide our children through the world, and teach them all the things they do not know about....
Reasons Why watching Anime is Great for Kids?
Reasons Why watching Anime is Great for Kids?
When kids are in their developmental phase, they get heavily influenced by the things that they spend their time with. It is the learning stage...
How your Kids to Study at Home and Complete all their Homework?
How your Kids to Study at Home and Complete all their Homework?
Most kids don’t like to do their homework. They know they have no other option but to follow the teacher’s instructions when they are in...
A Complete Guide to Kindergarten Online Classes
A Complete Guide to Kindergarten Online Classes
Children in Kindergarten have no idea how things work, how to read or write and what schoolwork is done at school. It is important to...

New Releases

Why Professional Heating Repair Services are Essential for your Home's Comfort?
December 19, 2025

Why Professional Heating Repair Services are Essential for your Home’s Comfort?

As the seasons change and temperatures plummet, the comfort of your home hinges on a well-functioning heating system. Maintaining a warm and cozy environment is…

YouTube Advertising Advantages, Limitations and best Practices
November 30, 2025
YouTube Advertising Advantages, Limitations and best Practices
Beyond the Mirror: The Rise of Preventive Skincare in Modern Wellness
November 24, 2025
Beyond the Mirror: The Rise of Preventive Skincare in Modern Wellness
WordPress Custom plugin Development Tutorial with Sample Codes
November 24, 2025
WordPress Custom plugin Development Tutorial with Sample Codes
b2b Email Marketing jobs and ZOHO Campaigns for professionals
July 7, 2025
b2b Email Marketing jobs and ZOHO Campaigns for professionals
YouTube Marketing Techniques to minimize Advertising Costs
July 2, 2025
YouTube Marketing Techniques to minimize Advertising Costs
Natural Hair Plantation for Women of any Age no Surgery
July 1, 2025
Natural Hair Plantation for Women of any Age with no Surgery
Eyeliner for Hooded Eyes to apply before applying Eyeshadow
July 1, 2025
Eyeliner for Hooded Eyes to apply before applying Eyeshadow
Comparing Paid and Free Website Builder for Small Business
July 1, 2025
Comparing Paid and Free Website Builder for Small Business
Google Search Console for SEO Tools for every Webmaster
July 1, 2025
Google Search Console for SEO Tools for every Webmaster
Digital Marketing Guest Post best practices to boost Sales
July 1, 2025
Digital Marketing Guest Post best practices to boost Sales
Deep Stretch Marks on Thighs and Belly during Pregnancy
June 26, 2025
Deep Stretch Marks on Thighs and Belly areas during Pregnancy
Fade Pregnancy Stretch Marks appear as Streaks or Lines on the Skin
June 26, 2025
Fade Pregnancy Stretch Marks appear as Streaks or Lines on the Skin
The best Guest Posting Website to boost your Online Presence
June 26, 2025
The best Guest Posting Website to boost your Online Presence
Digital Marketing Firms for Startup WordPress Blogs
June 25, 2025
Hi-Tech Digital Marketing Firms for Startup WordPress Blogs
Best Foods and 7 Day Diet Plan for Weight Loss help for Housewives
June 25, 2025
Prescribed Best Foods with 7 Day Diet Plan for Weight Loss Journey
Advanced Stage 3 Breast Cancer in Men and Women
June 25, 2025
Advanced Stage 3 Breast Cancer in Men and Women but Treatable
Explain Digital Marketing to Content Marketers for Leads
June 25, 2025
Explain Digital Marketing to Content Marketers for Sales Leads
explore us...
On-page SEO booster,
Google Friendly,
XML based
PHP/WP Sidebar
FREE Widgets
demo

OUR FACILITIES

  • Login
  • Our Background
  • Privacy
  • WordPress.org

CONTACT INFO

  • Reach Us
  • WhatsApp +918260272137

OUR SERVICES

  • Blog Posting Opportunity
  • *.fig, *.psd 2 html
  • Video Ads Designing
  • Setup your WordPress Blog
  • Optimizing Google PageSpeed
  • b2b Gmail IDs

WHY ONESTOP?

We are here to bring high Quality Information. As a multi-niche platform we have spend several years for Collecting various useful Stories. Dream to establish a domain where from you can get all your day today required information. We covers Animals to Zoology.
©2014-2025 JHARAPHULA, ALL RIGHTS RESERVED.