C# – How to access properties from global.asax in some other page’s code behind

asp.netcglobal-asax

Imagine I have a property defined in global.asax.

public List<string> Roles
{
    get
    {
        ...
    }
    set
    {
        ...
    }
}

I want to use the value in another page. how to I refer to it?

Best Answer

You can access the class like this:

((Global)this.Context.ApplicationInstance).Roles