Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
TrustedXslt Property
Collapse the table of content
Expand the table of content

XsltSettings.TrustedXslt Property

Gets an XsltSettings object that enables support for the XSLT document() function and embedded script blocks.

Namespace:  System.Xml.Xsl
Assembly:  System.Xml (in System.Xml.dll)

public static XsltSettings TrustedXslt { get; }

Property Value

Type: System.Xml.Xsl.XsltSettings
An XsltSettings object with the EnableDocumentFunction and EnableScript properties set to true.

Security noteSecurity Note

XSLT scripting should be enabled only if you require script support and you are working in a fully trusted environment. If you enable the document() function, you can restrict the resources that can be accessed by passing an XmlSecureResolver object to the Transform method.

The following example loads a style sheet with support for the XSLT document() function and embedded script blocks features enabled.

// Create a resolver and specify the necessary credentials.
XmlSecureResolver resolver = new XmlSecureResolver(new XmlUrlResolver(), "http://serverName/data/");
System.Net.NetworkCredential myCred;
myCred  = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain);  
resolver.Credentials = myCred;

// Create the XslCompiledTransform object and load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("http://serverName/data/script.xsl", XsltSettings.TrustedXslt, resolver);	

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft