1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Authenticated or not?

Authenticated or not?

4 posts, 0 answered
  1. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    10 Feb 2009
    Link to this post
    I created a WebControl to display my top navigation. It is pretty straight forward. It contains two panels. In one panel are the menu items (displaying in a <ul>) for when the user is NOT logged in (this is visible by default), and a panel that contains a slightly modified version for when users are logged in ("logout" instead of "login"..."edit profile" instead of "register"). The problem is, no matter whether I use the builtin ~/SiteFinity/Login.aspx or my own, when a user clicks on Login, when the properly login, they go back to the page and it still displays that it is NOT logged in. I went through the code to see what is happening, its very simple (located in Page_Load of the control):

    if (Request.IsAuthenticated)
            {
                pnlLoggedIn.Visible = true;
                pnlNone.Visible = false;
            }
            else
            {
                pnlLoggedIn.Visible = false;
                pnlNone.Visible = true;
            }

    Nothing too big. The code NEVER hits the authenticated code though UNLESS I go to a page OTHER than the page I logged in from. For example, if I come to the home page and login, I go back to the home page, and the control still displays as though it is not logged in. If I then navigate to another page, it shows up as having been logged in and the code in the top part of the "if" clause fires. Now, if I come back in and go to a different page, login, same thing...I come back to that page and it says I am not logged in, but if I go to the home page, it says I am. I am CONFUSED!

    Again this is using the Site Finity login page located in ~/SiteFinity/Login.aspx...I have created my own that uses the SAME code as you guys...and no dice. HELP!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Feb 2009
    Link to this post
    Hello Armysniper,

    Probably you have set Cache this page under page properties. The page is cached and it will not be refreshed until you publish/edit/delete a page or content. Removing the page cache should fix the problem.  Currently the whole page is cached. Output caching for the page caches the whole page, including the controls.

    In 3.6 we have planned to introduce cache substitution controls architecture. With these kind of controls, you would be able to cache everything on the page but them, so they will still be able to use dynamic data.
    I hope this helps.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    11 Feb 2009
    Link to this post
    Bingo! That would make sense! :) I am in 3.6 so how would I set it up so that this control is NOT cached but everything else is?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Feb 2009
    Link to this post
    Hi Armysniper,

    3.6 official release will be available in a day or two. Here is a link to Substitution Web Server Control Overview for ASP.NET.
    You can inherit some Sitefinity classes as well.

    Here is an example below using Login control:

    public partial class UserControls_FinalLoginControls_LoginControl : CacheSubstitutionUserControl 
        public virtual SubstitutionPageMode PageMode 
        { 
            get 
            { 
                return SubstitutionPageMode.Partial; 
            } 
        } 

    I hope this helps.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered