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.v20.1.dll

Declaration

public void SetRules(
    params IAccessRule[] rules
)
Public Sub SetRules(
    ParamArray rules As IAccessRule()
)

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.

See Also