473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Membership - Log Out Programatically

1
This is kind of a late response to a thread that I came across in the archive.
http://www.thescripts.com/forum/thread678632.html

I wanted the same functionality so I fired up Lutz Roeder's .NET Reflector (if you don't have this check it out) and decompiled the LoginStatus control. When you click the logout button on the LoginStatus control it calls this function:

Expand|Select|Wrap|Line Numbers
  1. Private Sub LogoutClicked(ByVal Source As Object, ByVal e As CommandEventArgs)
  2.     Dim args As New LoginCancelEventArgs
  3.     Me.OnLoggingOut(args)
  4.     If Not args.Cancel Then
  5.         FormsAuthentication.SignOut
  6.         Me.Page.Response.Clear
  7.         Me.Page.Response.StatusCode = 200
  8.         Me.OnLoggedOut(EventArgs.Empty)
  9.         Select Case Me.LogoutAction
  10.             Case LogoutAction.Refresh
  11.                 If ((Me.Page.Form Is Nothing) OrElse Not String.Equals(Me.Page.Form.Method, "get", StringComparison.OrdinalIgnoreCase)) Then
  12.                     Me.Page.Response.Redirect(Me.Page.Request.PathWithQueryString, False)
  13.                     Return
  14.                 End If
  15.                 Me.Page.Response.Redirect(Me.Page.Request.Path, False)
  16.                 Return
  17.             Case LogoutAction.Redirect
  18.                 Dim logoutPageUrl As String = Me.LogoutPageUrl
  19.                 If String.IsNullOrEmpty(logoutPageUrl) Then
  20.                     logoutPageUrl = FormsAuthentication.LoginUrl
  21.                 Else
  22.                     logoutPageUrl = MyBase.ResolveClientUrl(logoutPageUrl)
  23.                 End If
  24.                 Me.Page.Response.Redirect(logoutPageUrl, False)
  25.                 Return
  26.             Case LogoutAction.RedirectToLoginPage
  27.                 Me.Page.Response.Redirect(FormsAuthentication.LoginUrl, False)
  28.                 Return
  29.         End Select
  30.     End If
  31. End Sub
The most important line to see here is: FormsAuthentication.SignOut(). This is what logs out the user.

Hope this helps somebody.
Jul 31 '07 #1
1 3900
Plater
7,872 Expert 4TB
The signout is only effective if you are NOT using windows authentication. (As you never give up your computer credentials officially)
Jul 31 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Karen Hill | last post by:
I would like to be able to programatically check for group membership in an access database. For example, I would like to be able to check is someone is in the admin group before the program does...
9
by: Paul Keegstra | last post by:
Hi, I am currently working on an asp.net 2.0 web site that is a replacement of a classic asp web site. The current web site uses a Commerce Server 2002 database for storing user information. ...
3
by: ibiza | last post by:
Hi all, I am currently developing in asp.net 2.0 and I was at first impressed with the numerous login and user controls they provided to ease the task of managing users. But I am starting to...
2
by: Balaji | last post by:
Hi All, Can I use more than one membership provider for a given website? I understand only one of them could be default one. If yes, then how to programmatically access the other membership...
3
by: ryan.mclean | last post by:
Hello everyone, I am wondering, can the membership provider be changed at runtime? Perhaps the connectionStringName? I would like to use a different database based on the server the site is...
4
by: =?Utf-8?B?Q2hyaXMgQ2Fw?= | last post by:
I have been having some trouble with implementing a custom Membership Provider. We have a custom data store and business logic that pulls user information. I need some level of functionality...
4
by: Mick Walker | last post by:
Hi All, I have a situation where I am using a login control to log a user in to my web app. Under the LoginButton_Click handler of the login control, I retrive some custom user information from...
3
by: Glenn | last post by:
My current classic-ASP site has users, projects, roles and the 2.0 membership looks like a perfect fit, but I'm having trouble finding examples of how to have users that belong to different...
1
by: =?Utf-8?B?ZVByaW50?= | last post by:
Asp.Net v2.0 I have created a web application and I am using it from a single website and database. The web application has different ‘portals’ – each independent and I am using the...
2
by: NitinSawant | last post by:
Hello, How to Programatically Update Membership Role i.e. Rename a role using C#? In "Roles" class there are methods to add,read, delete roles but there is no method to Update the role......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.