Checking if actions are banned

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows how you can check if the current user action is banned for the current site. It uses a Label control with the ID lblError to display the error message:

 

[C#]

 

using CMS.SiteProvider;

using CMS.CMSHelper;

using CMS.GlobalHelper;

 

...

 

        // Check if current action is allowed

        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))

        {

            // If not error message is shown

            lblError.CssClass = "ErrorLabel";

            lblError.Text = "Requested action was canceled. Banned IP address.";

        }

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_checking_if_actions_are_banned.htm