AccessSettings.TrySetRules(IAccessRule[]) Method

Sets resource access rules.

Namespace: DevExpress.Security.Resources

Assembly: DevExpress.Data.v21.1.dll


public bool TrySetRules(
    params IAccessRule[] rules


Name Type Description
rules IAccessRule[]

An array of access rules.


Type Description

true, if the specified rule collection is registered successfully. Otherwise, false.


Before you set access rules, specify the resources for which these rules should be checked. To do this, use one of the following static properties:

  • StaticResources

    // Images can be loaded only from the "C:\\StaticResources\\" file directory and "" site
      bool success = DevExpress.Security.Resources.AccessSettings.StaticResources.TrySetRules(
          DevExpress.Security.Resources.UrlAccessRule.Allow("")) ;
      if (!success) System.Diagnostics.Debug.Print("Cannot change rules. The rules are already set.")
  • DataResources

    // JSON data can be loaded only from URLs; Excel data cannot be loaded from file directories (Excel data load from URLs is not supported)
      bool success = DevExpress.Security.Resources.AccessSettings.DataResources.TrySetRules(
          DevExpress.Security.Resources.DirectoryAccessRule.Deny()) ;
      if (!success) System.Diagnostics.Debug.Print("Cannot change rules. The rules are already set.")
  • ReportingSpecificResources

    // Style sheets cannot be loaded from file directories; only XML report layout serialization format is allowed
      bool success = DevExpress.Security.Resources.AccessSettings.ReportingSpecificResources.TrySetRules(
          DevExpress.Security.Resources.SerializationFormatRule.Deny(SerializationFormat.Xml)) ;
      if (!success) System.Diagnostics.Debug.Print("Cannot change rules. The rules are already set.")

The TrySetRules(IAccessRules[]) method can be called only once at runtime to prevent you from overriding rules. You should call this method when the application starts, before a control (Web End-User ReportDesigner) sets its own rules. Otherwise, the TrySetRules(IAccessRules[]) method does not register the specified rule collection and returns false.

You can use the SetRules(IAccessRule[]) method to set access rules. This method raises an exception if the rules are set earlier (if the reporting control has already set its rules).

See Also