Boolean to test if in administration panel?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
bemara579
Lieutenant (LT)
Lieutenant (LT)
Posts: 63
Joined: Thu Feb 19, 2009 6:15 pm

Boolean to test if in administration panel?

Post by bemara579 » Wed Apr 29, 2009 9:44 pm

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?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Boolean to test if in administration panel?

Post by mazhar » Thu Apr 30, 2009 10:08 am

Did you tried the Token, something like this

Code: Select all

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

bemara579
Lieutenant (LT)
Lieutenant (LT)
Posts: 63
Joined: Thu Feb 19, 2009 6:15 pm

Re: Boolean to test if in administration panel?

Post by bemara579 » Thu Apr 30, 2009 4:56 pm

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.

Post Reply