I am using a windows form application where a login form (login prompt) is used to authenticate an user and then open the application. Let us assume that I have a default admin username and password for logging in. When I click the close button of the application or choose File--> Exit, I want logout to be implemented so that the user has to again log in using his credentials when he starts the application for the next time. I want this to take place using C#
Any help on this guys?
preguntado el 08 de noviembre de 11 a las 08:11
Normally,if you close the application its credientials will automatically go off. The application will start from stratch the next time you start.
In the scenario where the login session is carried over, do your logout tasks on
FormClosing Evento o
FormClosed Event; when the form is closed, the session will not carry over.
You could implement logout actions inside the OnFormClosing() event handler of the form.
Your is user is authenticated only during the app start. If you will not implement some persistence mechanism to store the credentials or something like "cookie", then there's no need to deal with it - user will be prompted for credentials and authenticated on startup again.
you can add event handler for FormClosedEventHandler and log off the user on that event.
consider SystemEvents.SessionEnded event and Form.Closing Events