473,394 Members | 1,812 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.

FormsAuthentication.SignOut() not working in UserControl

When i add the following code below to a userControl it doesn't fire.
Any ideas?
Sub SignOut(ByVal objSender As Object, ByVal objArgs As EventArgs)
FormsAuthentication.SignOut()
Response.Redirect(Request.UrlReferrer.ToString())
End Sub
<input id="cmdSignOut" type="submit" Value="Sign Out" runat="server"
onserverclick="SignOut"
NAME="cmdSignOut">

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
9 2473
Hi have you placed something to test the sub say Response.Write("I have been
clicked") to test that does the event handler run at all?
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #2
Teemu thanks for the reply.
I tested it in an aspx page and it fires but doesn't in an ascx page.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:Ok**************@TK2MSFTNGP15.phx.gbl...
Hi have you placed something to test the sub say Response.Write("I have been clicked") to test that does the event handler run at all?
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #3
Is there anything special how you have the UC on the Page? Is it perhaps a
dynamical control?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #4
This is what i have :-
Top.ascx
------------
<%@ Control CodeBehind="_Header.ascx.vb" Language="vb"
AutoEventWireup="false" Inherits="Business.Commerce.C_Header" %>
' here i have some html and the Sign Out Button

Top.ascx.vb
-----------------
Public MustInherit Class C_Header
Inherits System.Web.UI.UserControl
' I placed the Sub Program here
End Class

Thats it.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Is there anything special how you have the UC on the Page? Is it perhaps a
dynamical control?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #5
Teemu i tried putting in a
Response.Write and it fires!
Bu the FormsAuthentication.SignOut() doesn't fire:(

My UserControl class looks like this below thanks:-
Imports System.Web.Security

Public MustInherit Class C_Header

Inherits System.Web.UI.UserControl

Protected WithEvents cmdSignOut As
System.Web.UI.HtmlControls.HtmlInputButton

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Sub SignOut(ByVal objSender As Object, ByVal objArgs As EventArgs) Handles
cmdSignOut.ServerClick

'delete the users auth cookie and sign out

FormsAuthentication.SignOut()

'redirect the user to their referring page

'Response.Redirect(Request.UrlReferrer.ToString())

'Response.Write("hello")

End Sub

End Class

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Is there anything special how you have the UC on the Page? Is it perhaps a
dynamical control?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #6
After doing some testing i noticed the FormAuthentication.SignOut() button
fires on some page and doesn't on the others (Even when testing with the
Response.Write)
I have 3 usercontrols on the paage :- Header,Menu and Footer.
And the button is in the Header userControl.
When i click on a link in the menu(usercontrol) and a page opens up in the
body section and then click on the SignOut()Button in the
Header(usercontrol) sometimes it fires and if i do te same for another link
in the Menu it doesn't fire.
In my web.config in the location path i have some pages i DENY USERS ="?"
Any ideas what might be wrong?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Is there anything special how you have the UC on the Page? Is it perhaps a
dynamical control?

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #7
You should do a redirect after calling SignOut, for exampl to a general
logout.aspx page. At that point it has been request which has been made with
privileges so just doing SignOut does nothing but remove the authentication
cookie. Next request from that would be one without permissions and access.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #8
Im doing a Redirect after a SignOut()
Guess i uncommented it out by mistake in the code i posted...
Whats happening is that sometimes it fires sometimes not.
Thx

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
You should do a redirect after calling SignOut, for exampl to a general
logout.aspx page. At that point it has been request which has been made with privileges so just doing SignOut does nothing but remove the authentication cookie. Next request from that would be one without permissions and access.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #9
Thx Teemu i got it working..
They were no FORM TAGS in the asp.net code arg!!!!( I was troubleshooting)
and again i changed it to an ASP:BUTTON.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
You should do a redirect after calling SignOut, for exampl to a general
logout.aspx page. At that point it has been request which has been made with privileges so just doing SignOut does nothing but remove the authentication cookie. Next request from that would be one without permissions and access.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff Johnson | last post by:
I'm using forms authentication to protect a subfolder within my site. I've got it working fine except for two issues: (1) When I do a RedirectFromLogin page I have to put a cookie path ("/"...
2
by: George Durzi | last post by:
When you call FormsAuthentication.SignOut(), is the FormsAuthentication cookie supposed to be destroyed automatically? I'm creating my FormsAuthentication cookie by doing: HttpCookie oCookie =...
0
by: Ed West | last post by:
Hello This SignOut code is not working, any ideas? TIA. public class logout : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { FormsAuthentication.SignOut();...
2
by: Grant Merwitz | last post by:
Hi, i am using forms authentication in an ASP.NET project I am setting the Forms authentication cookie by using: FormsAuthentication.RedirectFromLoginPage(UserName.Text, false); Now when i...
4
by: Matthias S. | last post by:
Hi there, I've created an application which is using Forms-based authentification. My Login-Button event handler looks somewhat like this: // validate the input, etc... // sUserName holds now...
3
by: David | last post by:
Hi all, I am having a slight issue with FormsAuthentication. I need to authenticate a user and while the page is still being processed, need to work with that authenticated user. I have set up...
3
by: Mark Olbert | last post by:
FormsAuthentication.SignOut() removes the authorization ticket from a user (and the user's roles), but does not change the user's identity. I need to be able to either revert the user to the...
0
by: Jon Paal | last post by:
FormsAuthentication.SignOut() not working, after executing the command pages are still accessible ???? how can I force the signout to kill the login ?
2
by: parez | last post by:
Hi ALl, I had problem with FormsAuthentication.SignOut(). It wasnt working. Looked arround and saw a lot of posts and different solutions to the problem. And some how (i dont nkow what...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.