Question

The site I'm creating has one section for non authenticated users and another for authenticated users.

(almost) every page in the site has a LoginStatus control which is located in the header and shown as 2 different buttons depending on status.

The problem I have, is that with pages in the non-authenticated folders of the site despite setting the LogoutPageUrl value in that control to the value "~login.aspx", the site merely refreshes the page but the control DOES show that the user is logged out by displaying the correct image in the control..and when clicking on that control again you ARE directed to the login page.

here's that control:

    <asp:LoginStatus CssClass="loginControlBtn" ID="LoginStatus2" 
    runat="server" LogoutPageUrl="~/login.aspx" 
    LoginImageUrl="~/images/LoginBtn.jpg"
    LogoutImageUrl="~/images/LogoutBtn.jpg" />

Also, once clicking on the login option on the LoginStatus control and logging in again you aren't directed to the page specified in the Login control, but end up back at the page you were at when you selected the Login option on the LoginStaus control.

here's the code for that Login control:

    <asp:Login ID="helpDeskLoginCtrl" runat="server" 
            DestinationPageUrl="~/admin/HelpDeskOptions.aspx" 
            style="text-align: justify" VisibleWhenLoggedIn="False" Width="421px">
        </asp:Login>

The site uses Forms authentication so that only authenticated users can view pages in the "~/admin" folder..and at least THAT part is working properly as when selecting to logout whilst at a page in that folder you're directed to the "~/login.aspx" page.

But then when you login again rather than going to

DestinationPageUrl="~/admin/HelpDeskOptions.aspx

as specified in the Login control you're directed back to the page you came from.

I'm really stumped.

Was it helpful?

Solution

well one of my college teachers helped me with the actual answer to this problem, and while I can't take credit for it I'm positing it here to help others who may encounter the same problem.

The property that caused my issue is the 'LogoutAction' control.

In the version of VS i'm using (2010) the default value is "Refresh" while it need to be changed to "Redirect" in order to always go to the page specified in the "LogoutPageURL" control and to not return from whence you came after logging back in.

hope this helps someone, Fenix

OTHER TIPS

This page should provide answers regarding the LoginStatus Class - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginstatus.aspx

You need to be checking the IsAuthenticated property of the Page object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top