Back to Devexpress

DirectoryAccessRule.Allow(String[]) Method

corelibraries-devexpress-dot-security-dot-resources-dot-directoryaccessrule-dot-allow-x28-system-dot-string-x29.md

latest8.7 KB
Original Source

DirectoryAccessRule.Allow(String[]) Method

Creates the DirectoryAccessRule that allows resource loading only from the file directories passed as the parameter.

Namespace : DevExpress.Security.Resources

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

csharp
public static DirectoryAccessRule Allow(
    params string[] directories
)
vb
Public Shared Function Allow(
    ParamArray directories As String()
) As DirectoryAccessRule

Parameters

NameTypeDescription
directoriesString[]

An array of file directories that this rule allows. Other directories are considered as denied in this application.

|

Returns

TypeDescription
DirectoryAccessRule

An instance of the DirectoryAccessRule class.

|

Remarks

You can pass nothing as the method’s parameter to create a rule that allows access to all file directories:

csharp
// Image load from file directories is allowed
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(DirectoryAccessRule.Allow());
vb
' Image load from file directories is allowed
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(DirectoryAccessRule.Allow())

Pass the file directories that should be accessible in the application to allow resource loading only from them:

csharp
// Image load is allowed only from the specified file directories.
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(DirectoryAccessRule.Allow("http://mysite.dev"));
vb
' Image load is allowed only from the specified file directories.
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(DirectoryAccessRule.Allow("http://mysite.dev"))

The following code snippets (auto-collected from DevExpress Examples) contain references to the Allow(String[]) 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.

web-forms-dashboard-update-parameter-master-filter-changed/CS/DXApplication33/Global.asax.cs#L8

csharp
DevExpress.Web.ASPxWebControl.CallbackError += new EventHandler(Application_Error);
    DevExpress.Security.Resources.AccessSettings.DataResources.SetRules(DevExpress.Security.Resources.DirectoryAccessRule.Allow(Server.MapPath("~/Content")), DevExpress.Security.Resources.UrlAccessRule.Allow());
}

asp-net-web-forms-splitter-resize-pane-to-fit-content/CS/Solution/Global.asax.cs#L7

csharp
void Application_Start(object sender, EventArgs e) {
    AccessSettings.DataResources.SetRules(DirectoryAccessRule.Allow(Server.MapPath("~/Content")), UrlAccessRule.Allow());
}

asp-net-web-forms-gridlookup-dropdown-with-grouped-items/CS/DXWebApplication1/Global.asax.cs#L7

csharp
DevExpress.Web.ASPxWebControl.CallbackError += new EventHandler(Application_Error);
    DevExpress.Security.Resources.AccessSettings.DataResources.SetRules(DevExpress.Security.Resources.DirectoryAccessRule.Allow(Server.MapPath("~/Content")), DevExpress.Security.Resources.UrlAccessRule.Allow());
}

mvc-dashboard-download-dashboard-xml-definition/CS/Global.asax.cs#L42

csharp
ModelBinders.Binders.DefaultBinder = new DevExpressEditorsBinder();
AccessSettings.StaticResources.TrySetRules(DirectoryAccessRule.Allow());

angular-reporting-handle-parameters-initialized-event/CS/ReportingWebApp/Startup.cs#L46

csharp
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) {
    var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(env.ContentRootPath, "..", "Content")).FullName);
    AccessSettings.ReportingSpecificResources.TrySetRules(contentDirectoryAllowRule, UrlAccessRule.Allow());

web-forms-dashboard-update-parameter-master-filter-changed/VB/DXApplication33/Global.asax.vb#L11

vb
AddHandler DevExpress.Web.ASPxWebControl.CallbackError, New EventHandler(AddressOf Application_Error)
    DevExpress.Security.Resources.AccessSettings.DataResources.SetRules(DevExpress.Security.Resources.DirectoryAccessRule.Allow(Server.MapPath("~/Content")), DevExpress.Security.Resources.UrlAccessRule.Allow())
End Sub

asp-net-web-forms-splitter-resize-pane-to-fit-content/VB/Solution/Global.asax.vb#L10

vb
Private Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    Call AccessSettings.DataResources.SetRules(DirectoryAccessRule.Allow(Server.MapPath("~/Content")), UrlAccessRule.Allow())
End Sub

asp-net-web-forms-gridlookup-dropdown-with-grouped-items/VB/DXWebApplication1/Global.asax.vb#L10

vb
AddHandler DevExpress.Web.ASPxWebControl.CallbackError, New EventHandler(AddressOf Application_Error)
    DevExpress.Security.Resources.AccessSettings.DataResources.SetRules(DevExpress.Security.Resources.DirectoryAccessRule.Allow(Server.MapPath("~/Content")), DevExpress.Security.Resources.UrlAccessRule.Allow())
End Sub

use-recaptcha-with-devexpress/VB/ReCaptcha/Global.asax.vb#L10

vb
AddHandler DevExpress.Web.ASPxWebControl.CallbackError, New EventHandler(AddressOf Application_Error)
    DevExpress.Security.Resources.AccessSettings.DataResources.SetRules(DevExpress.Security.Resources.DirectoryAccessRule.Allow(Server.MapPath("~/Content")), DevExpress.Security.Resources.UrlAccessRule.Allow())
End Sub

web-forms-customize-merge-field-names/VB/handle-customizemergefields-event/Global.asax.vb#L10

vb
AddHandler DevExpress.Web.ASPxWebControl.CallbackError, New EventHandler(AddressOf Application_Error)
    DevExpress.Security.Resources.AccessSettings.DataResources.SetRules(DevExpress.Security.Resources.DirectoryAccessRule.Allow(Server.MapPath("~/Content")), DevExpress.Security.Resources.UrlAccessRule.Allow())
End Sub

See Also

DirectoryAccessRule Class

DirectoryAccessRule Members

DevExpress.Security.Resources Namespace