Link to home
Start Free TrialLog in
Avatar of MOSSPOINT
MOSSPOINTFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Detecting VB.net login

Hi experts,

I'm writing a .net web application using visual basic and I'm struggling with the membership/login functionality.

I've got the membership database setup and have logged in after a fashon and I'm not sure if i'm doing it correctly.

Basically what I want to do is, after the user has logged in using the standard vb.net login tool and membership table lookup is navigate to a different web page and should the user log out redirect the user to the login page.  

Could someone give me a code example on how this is done?



Avatar of buraksarica
buraksarica
Flag of Türkiye image

You can use the login Control's loggedin event. See here for example :

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.loggedin.aspx

You will just redirect the user whereever you want after he/she logges-in.
Basically you would use session variables and master page / Base Page

In you master page Load event you would check for

If Not Session("IsLoggedIn") Is Nothing AndAlso Session("IsLoggedIn") = True Then
'user can proceed , run appropriate code here
Else
 response.redirect("login.aspx")
End If

In your login page on the OnloggedIn event of the logn control you would set Session("IsLoggedIn") = true

When the user logs out you would remove the Session.Remove("IsLoggedIn")

This approach will affect site ide access
ASKER CERTIFIED SOLUTION
Avatar of buraksarica
buraksarica
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MOSSPOINT

ASKER

Works a treat, thanks