Solved

Detecting VB.net login

Posted on 2010-11-23
4
794 Views
Last Modified: 2012-05-10
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?



0
Comment
Question by:MOSSPOINT
  • 2
4 Comments
 
LVL 5

Expert Comment

by:buraksarica
ID: 34195224
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.
0
 
LVL 4

Expert Comment

by:Andre412
ID: 34195815
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
0
 
LVL 5

Accepted Solution

by:
buraksarica earned 500 total points
ID: 34196220
There is no need to use a session variable while the author is using standart asp.net membership classes and methods. You can check if the request is authenticated (which means, user is logged in) with

Page.Request.IsAuthenticated

member. Also if you place a loginstatus control to masterpage, it automatically display a login and logout buttons, and take the action you desire automatically. Please refer to the http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginstatus.aspx and LogoutPageUrl property of it.
0
 

Author Closing Comment

by:MOSSPOINT
ID: 34203599
Works a treat, thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now