Click here to Skip to main content
15,891,607 members
Articles / Web Development / ASP.NET

Simple but robust web based file management system including user authentication

Rate me:
Please Sign up or sign in to vote.
3.17/5 (5 votes)
13 Jun 2006Public Domain1 min read 46.6K   1.2K   41  
This article will present a fully functional ASP.NET web application file management system written in pure VB. It allows for user authentication (Forms authentication), and based off that authenticate to allow/disallow functions within the site.
Public Class Login
    Inherits BasePage

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents lblCurrentUserName As System.Web.UI.WebControls.Label
    Protected WithEvents btnLogout As System.Web.UI.WebControls.Button
    Protected WithEvents RequiredFieldValidator2 As System.Web.UI.WebControls.RequiredFieldValidator
    Protected WithEvents RequiredFieldValidator1 As System.Web.UI.WebControls.RequiredFieldValidator
    Protected WithEvents Persist As System.Web.UI.WebControls.CheckBox
    Protected WithEvents btnLogon As System.Web.UI.WebControls.Button
    Protected WithEvents Msg As System.Web.UI.WebControls.Label
    Protected WithEvents tblLogOut As System.Web.UI.HtmlControls.HtmlTable
    Protected WithEvents tblLogon As System.Web.UI.HtmlControls.HtmlTable
    Protected WithEvents txtUserName As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtUserPassword As System.Web.UI.WebControls.TextBox

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Request.IsAuthenticated Then
            tblLogOut.Visible = True
            tblLogon.Visible = False
            lblCurrentUserName.Text = User.UserName
        Else
            tblLogOut.Visible = False
            tblLogon.Visible = True
        End If
    End Sub

    Protected Sub btnLogon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogon.Click
        Dim sUserName As String = txtUserName.Text
        Dim sPassword As String = txtUserPassword.Text
        Dim oUserInfo As WebDriveUserInfo = DataAccess.AuthenticateUser(sUserName, sPassword)
        If Not oUserInfo Is Nothing Then 
            Dim bIsPersistant As Boolean = Persist.Checked 
            Utility.SetUserInformation(oUserInfo, bIsPersistant)
        Else
            Msg.Text = "Invalid Credentials: Please try again."
        End If
    End Sub

    Protected Sub btnLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogout.Click
        Utility.SignOut()
        tblLogOut.Visible = False
        tblLogon.Visible = True
    End Sub
End Class


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions