Reply
login page in vb problem...
Old 03-15-2006, 08:12 PM login page in vb problem...
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
I have this script, (login.aspx.vb)
PHP Code:

Imports System
Imports System
.Web
Imports System
.Web.Security
Imports System
.Web.UI
Imports System
.Web.UI.HtmlControls
Imports System
.Web.UI.WebControls
Imports System
.Data
Imports System
.Data.SqlClient
Imports Microsoft
.VisualBasic
Namespace mygdi
Public Class login
    Inherits Page
    
Protected WithEvents btnLogin As System.Web.UI.WebControls.Button
    
Protected userid As TextBox
    
Protected passwd As TextBox
    
Protected rememberme As Checkbox
    
Protected lblSql As Label
        
Protected WithEvents valsummary As System.Web.UI.WebControls.ValidationSummary
        
Protected WithEvents valuserid As System.Web.UI.WebControls.RequiredFieldValidator
        
Protected WithEvents valpasswd As System.Web.UI.WebControls.RequiredFieldValidator
        
Protected lblMessage As Label

    
'*********************
    '  
Page Load Handler
    
'*********************

    Private Sub Page_Load(ByVal s As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            If Not Request.Cookies("userid") Is Nothing Then ' 
Load User ID from Cookies
                Dim useridwrk 
As HttpCookie Request.Cookies("userid")
                
userid.Text Server.HtmlEncode(useridwrk.Value)
            
End If 
        
End If
    
End Sub

    
'*****************
    '  
Login Handler
    
'*****************

    Private Sub btnLogin_Click(ByVal s As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim validpwd As Boolean
        Dim useridStr As String
        Dim passwdStr As String
        Dim sTmp As String
        Dim oewdb As ewdb = New ewdb()
        Dim userDataID As String
        useridStr = userid.Text
        passwdStr = passwd.Text
        validpwd = False

        ' 
User Table Checking
            
If Not validpwd Then
                Dim sSelect 
As String
                Dim sConnStr 
As String oewdb.ewConnStr  ' Get Connection String
                sTmp = Replace(useridStr, "'", "''") ' Adjust SQL for '
                sSelect = "
SELECT FROM [UsersWHERE [UserName] = '" & sTmp & "'"
                Dim objDataReader As SqlDataReader
                Dim oConn As New SqlConnection(sConnStr)
                Try
                    oConn.Open() ' Open the Connection to the Database
                    Dim objCommand As New SqlCommand(sSelect, oConn)
                    objDataReader = objCommand.ExecuteReader()
                    Dim useridDB, passwordDB As String
                    If objDataReader.Read() Then
                        useridDB = objDataReader("
UserName")
                        passwordDB = objDataReader("
Password")
                        If ((useridDB = useridStr) And (passwordDB = passwdStr)) Then
                            validpwd = True
                            userDataID = CStr(objDataReader("
UserID"))
                        End If
                    End If
                    objDataReader.Close()
                    oConn.Close()
                Catch oErr As SqlException
                    lblMessage.Text = oewdb.ewDataErrorMessage(oErr) ' Display Error Details
                    If lblMessage.Text = "" Then
                        lblMessage.Text = "
Access Login Database Error!"
                    End If
                    Exit Sub  ' And Stop Execution
                End Try
            End If
            If Not validpwd Then
                lblMessage.Text = "
Incorrect user ID or password"
            Else
                If rememberme.Checked Then ' Write User ID to Cookies
                    Response.Cookies("
userid").Value = useridStr
                    Response.Cookies("
userid").Expires = DateAdd("d", 365, Today) ' Change the Expiry Date of the Cookies Here
                End If
                Dim useridWrk As String = useridStr
                useridWrk += "
," & userDataID
                FormsAuthentication.RedirectFromLoginPage(useridWrk, False)
            End If
    End Sub

        Private Sub InitializeComponent()

        End Sub
    End Class
End Namespace 
and this script (default.aspx.vb)

PHP Code:

Imports System
Imports System
.Web
Imports System
.Web.UI
Namespace mygdi
Public Class ewdefault
    Inherits Page

    
'*********************
    '  
Page Load Handler
    
*********************

        Private 
Sub Page_Load(ByVal s As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
           
        End Sub
End 
Class
End Namespace 
Now I have a problem in logging in. when the login is succesfull, the page suppose to display the default.aspx . but instead this error occur,

"You are not authorized to view this page"
"HTTP Error 403 - Forbidden"

did I miss something in the default.aspx.vb ?
thanks folks.
__________________
$id ="waxxer";
$id = str_replace('x', 'l', $id);
echo $id;
echo " and Marj";
waller is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-16-2006, 04:08 AM Re: login page in vb problem...
Minaki's Avatar
Cheerleader

Posts: 1,626
Location: Guildford, UK
Is your web.config file set up to use Forms Authentication, and have you set up default.aspx as a protected page in web.config?

Is the Default Document in IIS set up to be default.aspx? You usually get a 403 when you request a directory as opposed to a file, there is no default document set up, and directory listing is denied.

Also, you don't need to bother with the cookie yourself - all you need to do is call RedirectFromLoginPage with the second parameter as True and it will presist the cookie.
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"
Inoxia Pyrotechnics Supplies | Surrey Angels Cheerleading Squad
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-19-2006, 09:07 PM Re: login page in vb problem...
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Thanks man. That helps a lot.
__________________
$id ="waxxer";
$id = str_replace('x', 'l', $id);
echo $id;
echo " and Marj";
waller is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to login page in vb problem...
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12182 seconds with 13 queries