如何使用会话和访问数据库使用ASP.NET构建登录页面? [英] How to Build Login Page with ASP.NET using Session and Access Database?

查看:66
本文介绍了如何使用会话和访问数据库使用ASP.NET构建登录页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有两个第一页Login.aspx,第二个是Inbox.aspx

使用正确的详细信息登录时,登录页面将我重定向到Inbox.aspx页面

现在,我想检查Inbox.aspx页面加载事件是否为有效用户登录.

我的基本概念是阻止来宾用户访问收件箱页面.

如何检查?我在VS 2008中使用Access 2003数据库.

登录按钮代码:

Hi
I have two Page One Login.aspx and Second is Inbox.aspx

When I login with Correct Details, Login Page Redirect me to a Inbox.aspx Page

Now I want to Check on Inbox.aspx Page Load Event for Valid User Login or Not.

My Basic Concept is to Block Access the Inbox Page from Guest User.

How to Check it? I use Access 2003 Database with VS 2008.

LOGIN BUTTON CODE :

Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & Server.MapPath("TEST.mdb"))
        Dim cmd As OleDbCommand
        Dim MyReader As OleDbDataReader
        con.Open()
        cmd = New OleDbCommand("Select Pass from User where Uname ='" & uname.Text & "';", con)
        MyReader = cmd.ExecuteReader()
        If Not MyReader.Read() Then
            statuslbl.Text = "Wrong Details, Enter Username and Password Again."
        Else
            If MyReader(0).ToString() = passwrd.Text Then
                Response.Redirect("Inbox.aspx")
            Else
                statuslbl.Text = "Wrong Password."
            End If
        End If

推荐答案

解决了我自己的问题


SOLVED MYS SELF

with
If Session("Loggedser") Is Nothing Then

Response.Redirect("Login.aspx", False)
End If


这篇关于如何使用会话和访问数据库使用ASP.NET构建登录页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆