Skip to main content

AccessSettings.SetRules(IAccessRule[]) Method

Sets resource access rules. Raises an exception if this method is called for the second time while the application is running.

Namespace: DevExpress.Security.Resources

Assembly: DevExpress.Data.v24.2.dll

Declaration

public void SetRules(
    params IAccessRule[] rules
)

Parameters

Name Type Description
rules IAccessRule[]

An array of access rules.

Remarks

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.SetRules(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.SetRules(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.SetRules(DirectoryAccessRule.Deny(), SerializationFormatRule.Deny(SerializationFormat.Xml));
    

The SetRules(IAccessRule[]) method can be called only once while the application is running. This allows rules to not be overridden. An attempt to call this method for the second time leads to an exception. So, call this method when your application starts to specify rules before a control (for example, Web End-User ReportDesigner) sets its rules. Alternatively, use the TrySetRules(IAccessRule[]) method. It does not raise an exception, but returns false if a control sets rules earlier.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetRules(IAccessRule[]) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also