jacobymatt
asked on
Problem with FormAuthentication.SignOut() when accessed on web server
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.SignOu t()
Response.Redirect("login.a spx")
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">L ogout</asp :linkbutto n>
Private Sub lButLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lButLogout.Click
FormsAuthentication.SignOu
Response.Redirect("login.a
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">L
ASKER
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('lB utLogout', ")
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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...?
ASKER
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.
good luck