Exiting redirect mode to ASP.NET doesn't work

I have a testwebsite in which I made Loginstatus

[ <asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect"     LogoutText="Log Out" LogoutPageUrl="Account/Logout.aspx"/> ]

      

However, when I click the "Exit" button on the screen. it goes to that url and doesn't actually call the exit page.

"HTTP: //localhost/TestWebSite/Account/Login.aspx ReturnUrl =% 2fTestWebSite% 2fAccount% 2fLogout.aspx"

I was trying to get it to call some logic to log out and remove the db line for my custom provider. This logic has been placed in page load logout.aspx.cs

Session.RemoveAll();

FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();

      

but of course it is not called ... and of course if I login again with ReturnUrl it will immediately call the exit page. I am confused because this is not the behavior that I expected and did not document.

Please, help.

Thank!

+3


source to share


1 answer


I'm not sure if this is what you are looking for, but if you just want to run the code after the user is logged out, use this method http://msdn.microsoft.com/en-us/library/system.web.ui. webcontrols.loginstatus.onloggedout.aspx

Called when the user presses the logout button and logs out. You can put your code in there and then redirect to your exit page if you like.



Note. It is also a method that you can use to ensure that a user meets certain conditions when logging out and even unregistering. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginstatus.onloggingout.aspx

Hope it helps.

+2


source







All Articles