Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I would like to Logout the application in c#.net Windows application and login form should be opened at the time of Logout Can any one help
Posted 8-Jun-12 1:34am
Edited 8-Jun-12 1:45am
v2
Comments
Sandeep Mewara at 8-Jun-12 7:46am
   
Logout in Winforms?
RDBurmon at 8-Jun-12 8:25am
   
Thanks Everyone who replied to this thread , So Anand, I think you have got enough response and you should be able to mark it as your answer and close the thread.
   
Guys.. Op wants the answer for Winforms.. Not asp.net. He wants that when the click on 'Log out' button in the Windows app, then the login form should be displayed by default..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Write the following logout code in logout button click event
FormsAuthentication.SignOut();
Session["Name"].Abandon();
Response.Redirect("Login.aspx");
and in
login.aspx
page load event write the following statement.
Response.Cache.SetNoStore();
it should be the first statement in the page load event.
if you are using the master pages then write the above statement in the master page load event.
  Permalink  
Comments
Member 9217015 at 6-Jul-12 2:29am
   
Sir I have a very simple question.i.e
Q1.How to match data from tables of MySql database in C# .net window application ?
Q2. Can we check login and logout time of a user/member? If yes then plZ help me....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Simply use
 
 Session.Abondon(); 
//and redirect user to login page.
Response.Redirect("Login.aspx");
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use
 
Response.Redirect("login.aspx"); /
Clear previous session's, if you have any
 
Thanks,
SP
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hi, If you are using FormsAuthentication then on Logout Button click write the following code
            Session.Clear();
            Session.Abondon();
            FormsAuthentication.SignOut();
            Response.Redirect("Home.aspx");
and if you are not using FormsAuthentication then simply
            Session.Clear();
            Session.Abondon(); 
            Response.Redirect("Home.aspx");
will work.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Here is an article that shows you how to build a control that will do what you are asking (redirect the user to a login page when their session has timed out):
 
http://www.eggheadcafe.com/tutorials/asp-net/7262426f-3c65-4c90-b49c-106470f1d22a/build-an-aspnet-session-timeout-redirect-control.aspx[^]
 
There are other solutions, including simpler ones if that is what you are looking for, here:
 
http://forums.asp.net/p/1104278/1685530.aspx[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,631
1 Sergey Alexandrovich Kryukov 6,345
2 CPallini 5,230
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 8 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100