Solved

Problem with FormAuthentication.SignOut() when accessed on web server

Posted on 2004-09-20
6
223 Views
Last Modified: 2012-06-27
I have built an asp.net application that I developed on my local machine so that I have been accessing it through my localhost.  The application uses forms authentication and checks username and password values against a database which has all been working fine.  On several of my pages for this application I have a linkbutton control to give the user the option to logout.  The codebehind methods for these buttons are all:
Private Sub lButLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lButLogout.Click
        FormsAuthentication.SignOut()
        Response.Redirect("login.aspx")
    End Sub

Now at first when I clicked on these linkbuttons they would only make the page post back to itself, then I (just guessing around) set the CausesValidation attribute of the linkbutton to False.  That seemed to fix the problem and all the logout linkbuttons were working.  I just transferred the application over to a web server and have been testing the site there and now I have noticed that just one of my linkbuttons is still only making the form post back and is not signing out and taking the user back to the login page.  I checked to make sure the CausesValidation attribute for that linkbutton was false and it is.  So as far as I can tell all my logout linkbuttons are identical but one is not working.  Here is the linkbutton in my html:
<asp:linkbutton id="lButLogout" runat="server" ForeColor="Blue" CausesValidation="False">Logout</asp:linkbutton>
0
Comment
Question by:jacobymatt
  • 2
  • 2
  • 2
6 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 12105756
just delete that link button and drag and drop a new one and try....

good luck
0
 

Author Comment

by:jacobymatt
ID: 12105997
no, that did not help.  Remember, the linkbutton that is not executing the logout or redirect to the login page works fine when I am accessing the site through my local host, but when I access through the web server I just deployed this application to, this one linkbutton only reposts the page.  One more thing I thought was wierd is that when I hover over the logout linkbutton giving me problems, the javascript message in the bottom left reads: javascript:_doPostBack('lButLogout', ")

But it also displays this message when I hover over the other logout linkbuttons I have created that are working so maybe there's nothing wrong with that.  
0
 
LVL 9

Accepted Solution

by:
hismightiness earned 50 total points
ID: 12106083
It sounds like your postback is getting caught by another event before hitting the handler for the click event OR there is not an event handler written.  My first thought you already covered with the "CausesValidation" property.  

Make sure that all your event handlers are the same as what you posted above and that they all have "Handles buttonid.Click" at the end.  Also, make sure that the ID and "Handles id.Click" are referencing the same button id.  I have found that through regular updates and editing, Visual Studio will sometimes remove the "Handles id.Click" from the Sub when working with the buttons.

On a seperate note, why not put your logout button into one User Control so you only have to worry about one button and one button clicked event?  This would be much easier for you to manage and debug.  All you would have to do is drag and drop the user control onto the pages you wanted the user to be able to log out from.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:hismightiness
ID: 12106103
The mouseover window status is typical depending on the object you are hovering over.  This may sound like a dumb question, but are you updating the files in the bin when making it live on the web server?
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12112434
yeah that means something is not causing the post back....like the cause validation..is the only thing i can see .. so inspite of deleting that button and dragging and dropping the other one it behaves like that...that really is weird...is it only on that page always...?

0
 

Author Comment

by:jacobymatt
ID: 12112531
Well, hismightiness aput me on the right track.  I had a function in my form load that was enclosed with the condition 'if ispostback = false then' so I tried wrapping the signout and redirect code inside a 'if ispostback = true then'  and it worked.  Still dont really have the hang of the postbacks but I guess this is learning.  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Trouble with References... 5 44
Convert to Hour/minute textbox and compare 3 53
How do ASP.NET and MVC work together? 4 29
Turn on intranet settings 1 40
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now