Page 1 of 1

Boolean to test if in administration panel?

Posted: Wed Apr 29, 2009 9:44 pm
by bemara579
I have custom code in my global.asax file that I would want to only run in the public side, but not when an administrator is logged into the admin control panel. Right now I am figuring which side I am on like this:

Code: Select all

if (!Request.FilePath.StartsWith("/Admin/"))
{
     // Only change theme for public side
     Page.Theme = "YellowJacket";
}
One day someone can decide that they want to move the Admin files in a Secure folder, and this code would not work anymore. So is there a better, "native" way to test than to just check if I am in the Admin folder?

Re: Boolean to test if in administration panel?

Posted: Thu Apr 30, 2009 10:08 am
by mazhar
Did you tried the Token, something like this

Code: Select all

if (Token.Instance.User.IsAdmin)
        {
            //Admin
        }
        else
        { 
            //Normal User
        }

Re: Boolean to test if in administration panel?

Posted: Thu Apr 30, 2009 4:56 pm
by bemara579
I tried your suggestion, but it does not work properly because sometimes the admin views the public side of the page, in which case I still want my condition to apply. In other words, I want the admin to also see the "YellowJacket" theme on the front end in my example, but I do not want the theme to apply to the admin control panel.