A newer version of this page is available. Switch to the current version.

AccessSettings.TrySetRules(IAccessRule[]) Method

Sets resource access rules.

Namespace: DevExpress.Security.Resources

Assembly: DevExpress.Data.v19.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 "http://mysite.dev" site
    DevExpress.Security.Resources.AccessSettings.StaticResources.TrySetRules(DirectoryAccessRule.Allow("C:\\StaticResources\\"), UrlAccessRule.Allow("http://mysite.dev"));
  • 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)
    DevExpress.Security.Resources.AccessSettings.DataResources.TrySetRules(UrlAccessRule.Allow(), DirectoryAccessRule.Deny()); 
  • ReportingSpecificResources

    // Style sheets cannot be loaded from file directories; only XML report layout serialization format is allowed
    DevExpress.Security.Resources.AccessSettings.ReportingSpecificResources.TrySetRules(DirectoryAccessRule.Deny(), SerializationFormatRule.Deny(SerializationFormat.Xml));

The TrySetRules(IAccessRules[]) method can be called only once during the application run. This allows rules not to be overridden. So, call this method when the application starts to specify rules before a control (for example, Web End-User ReportDesigner) sets its 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 a control sets its rules earlier.

See Also