Back to Devexpress

UrlAccessRule.Allow(String[]) Method

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

latest8.6 KB
Original Source

UrlAccessRule.Allow(String[]) Method

Creates the UrlAccessRule rule that allows resource loading only from the URLs passed as the parameter.

Namespace : DevExpress.Security.Resources

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

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

Parameters

NameTypeDescription
urlsString[]

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

|

Returns

TypeDescription
UrlAccessRule

An instance of the UrlAccessRule class.

|

Remarks

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

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

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

csharp
// Image load is allowed only from the specified URL.
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(UrlAccessRule.Allow("http://mysite.dev"));
vb
' Image load is allowed only from the specified URL.
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(UrlAccessRule.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());
}

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

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(env.ContentRootPath, "..", "Content")).FullName);
AccessSettings.ReportingSpecificResources.TrySetRules(contentDirectoryAllowRule, UrlAccessRule.Allow());
if (env.IsDevelopment()) {

angular-reporting-use-custom-ui-elements-to-specify-parameters/CS/ReportingWebApp/Startup.cs#L46

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(env.ContentRootPath, "..", "Content")).FullName);
AccessSettings.ReportingSpecificResources.TrySetRules(contentDirectoryAllowRule, UrlAccessRule.Allow());
if (env.IsDevelopment()) {

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

UrlAccessRule Class

UrlAccessRule Members

DevExpress.Security.Resources Namespace