I am having issues when a user logs in via asp Login control, the IsAuthenticated still seems to come up false... ( yes the username and password is correct)
Can anyone tell me what I might be missing ?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load setupForm()
If (Page.IsPostBack) Then 'Dim loggedIn As Boolean = HttpContext.Current.Request.IsAuthenticated End If
If (Not Page.IsPostBack) Then 'Popup dialog won't fire if user is already in. If (Request.IsAuthenticated) Then mpeLogin.Enabled = False pnLogin.Visible = False logStatus.Visible = True logName.Visible = True
Else mpeLogin.Enabled = True pnLogin.Visible = True logStatus.Visible = False logName.Visible = False End If End If
End Sub
Private Sub setupForm()
' set the Login control properties lgLogin.CreateUserText = _JoinNowText lgLogin.CreateUserUrl = _JoinNowURL lgLogin.PasswordRecoveryText = _PasswordRecoveryText lgLogin.PasswordRecoveryUrl = _PasswordRecoveryUrl lgLogin.InstructionText = _InstructionText lgLogin.HelpPageText = _HelpPageText lgLogin.HelpPageUrl = _HelpPageUrl lgLogin.DestinationPageUrl = _DestinationPageUrl lgLogin.RememberMeSet = _RememberMeSet lgLogin.RememberMeText = _RememberMeText
pnLogin.CssClass = _LoginPanelCss lblBeforeButton.Text = _LoginPanelLabel pnLogin.Width = _LoginPanelWidth
End Sub 'Continue to display the popup dialog and failure text if login failed. Protected Sub lgLogin_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles lgLogin.Authenticate Dim name As String = HttpContext.Current.User.Identity.Name
'Add authentication logic here. 'e.Authenticated = ((lgLogin.UserName = "gbeford") And (lgLogin.Password = "spring!")) e.Authenticated = HttpContext.Current.Request.IsAuthenticated Dim test As Boolean = HttpContext.Current.User.Identity.IsAuthenticated Dim isLoggedIn As Boolean = FormsAuthentication.Authenticate(lgLogin.UserName, lgLogin.Password)
If (Not e.Authenticated) Then mpeLogin.Show() End If
End Sub