Back to Devexpress

UrlAccessRule.Deny(String[]) Method

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

latest5.9 KB
Original Source

UrlAccessRule.Deny(String[]) Method

Creates the UrlAccessRule that denies resource loading 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 Deny(
    params string[] urls
)
vb
Public Shared Function Deny(
    ParamArray urls As String()
) As UrlAccessRule

Parameters

NameTypeDescription
urlsString[]

An array of URLs that this rule denies. Other URLs are considered as allowed 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 denies access to all URLs:

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

Pass the URLs that should not be accessible in the application to deny resource loading from them:

csharp
// Image load from the specified URL is denied. Images from other URLs are accessible.
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(UrlAccessRule.Deny("http://mysite.dev"));
vb
' Image load from URLs is denied
DevExpress.Security.Resources.AccessSettings.StaticResources.SetRules(UrlAccessRule.Deny())

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

reporting-asp-net-core-content-security-policy/CS/CSPExample/Startup.cs#L48

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(env.ContentRootPath, "..", "Content")).FullName);
AccessSettings.ReportingSpecificResources.SetRules(contentDirectoryAllowRule, UrlAccessRule.Deny());
DevExpress.XtraReports.Configuration.Settings.Default.UserDesignerOptions.DataBindingMode = DevExpress.XtraReports.UI.DataBindingMode.Expressions;

reporting-asp-net-core-specify-parameters-in-url-query-string/CS/ReportingApp/Startup.cs#L44

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(env.ContentRootPath, "..", "Content")).FullName);
AccessSettings.ReportingSpecificResources.SetRules(contentDirectoryAllowRule, UrlAccessRule.Deny());
var reportingLogger = loggerFactory.CreateLogger("DXReporting");

reporting-asp-net-core-specify-parameters-on-button-click/CS/ReportingApp/Startup.cs#L44

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(env.ContentRootPath, "..", "Content")).FullName);
AccessSettings.ReportingSpecificResources.SetRules(contentDirectoryAllowRule, UrlAccessRule.Deny());
var reportingLogger = loggerFactory.CreateLogger("DXReporting");

reporting-asp-net-core-customize-parameters-panel/CS/Program.cs#L47

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(builder.Environment.ContentRootPath, "Content")).FullName);
AccessSettings.ReportingSpecificResources.SetRules(contentDirectoryAllowRule, UrlAccessRule.Deny());
app.UseDevExpressControls();

reporting-asp-net-core-standalone-parameters-panel/CS/DXWebApplication1/Program.cs#L46

csharp
var contentDirectoryAllowRule = DirectoryAccessRule.Allow(new DirectoryInfo(Path.Combine(builder.Environment.ContentRootPath, "Content")).FullName);
AccessSettings.ReportingSpecificResources.SetRules(contentDirectoryAllowRule, UrlAccessRule.Deny());
app.UseDevExpressControls();

See Also

UrlAccessRule Class

UrlAccessRule Members

DevExpress.Security.Resources Namespace