Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2009, 11:32 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default How to log a user out by code? + asp.net membership

Hi
I am not using the loginview control since it just caused me too many problems so I am just making my own. Basically right now I have a hyperlink and on every aspx page I have on page_load checking if the user is logged in or not.


If the user is logged in then I just change the hyperlink to say logout and change the path to the logout.aspx file. If they are authenicated then I just make sure it says login and the path points to the login.aspx.
Now on my logout.aspx file in the page load I have



FormsAuthentication.SignOut();


Now I have some stuff in a loginView control and I noticed that even though the persons been signed out they still see the menu items as if they where still logged in. If I refresh though they go always.
So what am I missing to make these go away? Am I not full logged out at this time?
 
Old April 5th, 2009, 04:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The event that logs the user out probably fires too late, so your other controls already made up their mind about whether the user is logged in or not.

A common way to fix this is to redirect away (possibly to the same page) after the Signout call.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about Asp.net Membership chobo2 ASP.NET 3.5 Basics 3 April 2nd, 2009 04:02 PM
ASP.NET Membership and ActiveDirectory Quick209 ASP.NET 2.0 Professional 0 June 13th, 2007 12:41 PM
Help with ASP.NET Membership VerbatimBOT SQL Server 2000 6 May 2nd, 2007 01:58 PM
Roles and membership asp.net 2 zeeshannasir ASP.NET 2.0 Basics 2 September 15th, 2006 07:24 AM
odbc user dsn in asp.net problem with code ashu10dec ASP.NET 1.0 and 1.1 Professional 0 February 23rd, 2006 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.