Skip to main content
All docs
V25.2
  • ASPxSpreadsheetUriValidationContext Class

    Identifies the context of an URL validation request in a ASPxSpreadsheet component.

    Namespace: DevExpress.Web.ASPxSpreadsheet

    Assembly: DevExpress.Web.ASPxSpreadsheet.v25.2.dll

    NuGet Package: DevExpress.Web.Office

    Declaration

    public sealed class ASPxSpreadsheetUriValidationContext :
        ASPxOfficeUriValidationContext

    Remarks

    The ASPxSpreadsheet 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 ASPxSpreadsheetUriValidationContext instance identifies the ASPxSpreadsheet 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 via the UI, clipboard, or API.

    Use the DocumentInfo property instead to identify the event sender.

    Note that the ASP.NET Core Spreadsheet component does not have the Editor property.

    The following code snippet enables requests to internal network resources in the specified Spreadsheet document:

    using System;
    using DevExpress.Security.Resources;
    using DevExpress.Web.ASPxSpreadsheet;
    
    protected void Application_Start(object sender, EventArgs e) {
        AccessSettings.UriValidated += OnUriValidated;
    }
    
    void OnUriValidated(object sender, UriValidatedEventArgs e) {
        // Checks if a validation request comes from ASPxSpreadsheet
        if(e.ValidationContext is ASPxSpreadsheetUriValidationContext spreadsheetContext) {
            if(spreadsheetContext.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.

    Inheritance

    Object
    DevExpress.Security.UriValidationContext
    ASPxOfficeUriValidationContext
    ASPxSpreadsheetUriValidationContext
    See Also