Auth.OnlyAdminAllowed C# (CSharp) Method

OnlyAdminAllowed() public static method

Redirect tot the Denied.aspx if this isn't an admin user
public static OnlyAdminAllowed ( ) : void
return void
    public static void OnlyAdminAllowed()
    {
        string AdminGroup = ConfigurationManager.AppSettings["AdminGroup"];
        if (!HttpContext.Current.User.IsInRole(AdminGroup)) {
          HttpContext.Current.Response.Redirect("denied.aspx");
        }
    }

Usage Example

コード例 #1
0
ファイル: Edit.aspx.cs プロジェクト: elgogle/SimpleCSharpWiki
    protected void Page_Load(object sender, EventArgs e)
    {
        Auth.OnlyAdminAllowed();

        urlpath = Util.PathFromUrl;

        if (!IsPostBack)
        {
            Wiki.Page page = DbServices.FindPageByUrlpath(urlpath);
            litHeader.Text       = page.path;
            txtPath.Text         = page.path;
            txtRichEditor.Text   = page.contents;
            hlCancel.NavigateUrl = "./?" + urlpath;

            // If it's the home page, don't allow them to change the path or remove it
            if (urlpath == "/")
            {
                txtPath.Enabled  = false;
                bnDelete.Enabled = false;
            }
        }
    }
All Usage Examples Of Auth::OnlyAdminAllowed