ASPxRichEditUriValidationContext Class
Identifies the context of an URL validation request in a ASPxRichEdit component.
Namespace: DevExpress.Web.ASPxRichEdit
Assembly: DevExpress.Web.ASPxRichEdit.v25.2.dll
NuGet Package: DevExpress.Web.Office
Declaration
Remarks
The ASPxRichEdit component and its MVC, Bootstrap, and Core counterparts validate URL schemes to prevent potential threats.
To override URL validation behavior, handle the UriValidated event. In the event handler, an ASPxRichEditUriValidationContext instance identifies the ASPxHtmlEditor component initiated the URL validation (using the Editor property). An Editor property value can be null in the following cases:
- You import documents that contain external images.
- You insert images the via UI, clipboard, or API.
Use the DocumentInfo property instead to identify the event sender.
The following code snippet enables requests to internal network resources in the specified Rich Text Editor document:
using System;
using DevExpress.Security.Resources;
using DevExpress.Web.ASPxRichEdit;
protected void Application_Start(object sender, EventArgs e) {
AccessSettings.UriValidated += OnUriValidated;
}
void OnUriValidated(object sender, UriValidatedEventArgs e) {
// Checks if a validation request comes from ASPxRichEdit
if(e.ValidationContext is ASPxRichEditUriValidationContext richEditContext) {
if(richEditContext.DocumentInfo.DocumentId == "MyDocumentId" && e.Uri != null) {
// Specifies allowed hosts
if(e.Uri.IdnHost.Equals("localhost", StringComparison.OrdinalIgnoreCase)) {
e.Valid = true;
}
}
}
}
Refer to the following help topic for additional information: Safe URL Validation.