I have a testwebsite in which I've made the Loginstatus to be
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="Account/Logout.aspx"/> ]
However when I click the Log Out on the screen .. it goes to this url and doesn't actually call the logout page.
"http://localhost/TestWebSite/Account/Login.aspx?ReturnUrl=%2fTestWebSite%2fAccount%2fLogout.aspx"
I was trying to make it call some logic to logout and remove a db row I have for my custom membership Provider. This logic was placed in the page load of the logout.aspx.cs
Session.RemoveAll();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
but of course it's not being called... and of course if I login again with the ReturnUrl there, it immediately calls the logout page. I'm confused since this is not the behavior that I expected nor is documented.
Please help.
Thanks!
I'm not sure if this is what your looking for but if you simply want to run some code after the user has logged out then use this method http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginstatus.onloggedout.aspx
It is called when the user presses the logout button and has been logged out. You can put your code there and then redirect to your logout page if you'd like.
Note: Theres also this method which you can use to make sure the user meets certain conditions when logging out and even cancel logging out. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginstatus.onloggingout.aspx
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With