This documentation is archived and is not being maintained.

SignedXml.XmlDsigBase64TransformUrl Field

Represents the Uniform Resource Identifier (URI) for the base 64 transformation. This field is constant.

Namespace:  System.Security.Cryptography.Xml
Assembly:  System.Security (in System.Security.dll)

public const string XmlDsigBase64TransformUrl

The value of the XmlDsigBase64TransformUrl field is "".

Use this field to conveniently supply a value to one of the URI attributes of an element used for XMLDSIG.

The XmlDsigBase64Transform class implements the transform described by the XmlDsigBase64TransformUrl field.

For more information, see the World Wide Web Consortium (W3C) specification at

The following code example demonstrates how to use members of the XmlDsigBase64Transform class.

using System;
using System.IO;
using System.Xml;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;

class Class1
    static void Main(string[] args)
        // Encrypt an XML message

        // Using XmlDsigBase64Transform resolving a Uri.
        Uri baseUri = new Uri("");
        string relativeUri = "msdn";
        Uri absoluteUri = ResolveUris(baseUri, relativeUri);

        Console.WriteLine("This sample completed successfully; " +
            "press Enter to exit.");

    // Encrypt the text in the specified XmlDocument. 
    private static void EncryptXML(XmlDocument xmlDoc)
        XmlDsigBase64Transform xmlTransform = new XmlDsigBase64Transform();

        // Ensure the transform is using the proper algorithm.
        xmlTransform.Algorithm = SignedXml.XmlDsigBase64TransformUrl;

        // Retrieve the XML representation of the current transform.
        XmlElement xmlInTransform = xmlTransform.GetXml();

        Console.WriteLine("Xml representation of the current transform: ");

        // Retrieve the valid input types for the current transform.
        Type[] validInTypes = xmlTransform.InputTypes;

        // Verify the xmlTransform can accept the XMLDocument as an 
        // input type. 
        for (int i=0; i<validInTypes.Length; i++)
            if (validInTypes[i] == xmlDoc.GetType())
                // Demonstrate loading the entire Xml Document.

                // This transform is created for demonstration purposes.
                XmlDsigBase64Transform secondTransform =
                    new XmlDsigBase64Transform();

                string classDescription = secondTransform.ToString();

                // This call does not perform as expected. 
                // LoadInnerXml is overridden by the XmlDsigBase64Transform 
                // class, but is stubbed out.


        Type[] validOutTypes = xmlTransform.OutputTypes;

        for (int i=0; i<validOutTypes.Length; i++)
            if (validOutTypes[i] == typeof(System.IO.Stream))
                    Type streamType = typeof(System.IO.Stream);
                    CryptoStream outputStream = (CryptoStream) 

                    // Read the CryptoStream into a stream reader.
                    StreamReader streamReader =
                        new StreamReader(outputStream);

                    // Read the stream into a string.
                    string outputMessage = streamReader.ReadToEnd();

                    // Close the streams.

                    // Display to the console the Xml before and after 
                    // encryption.
                    Console.WriteLine("Encoding the following message: " +
                    Console.WriteLine("Message encoded: " + outputMessage);
                catch (Exception ex)
                    Console.WriteLine("Unexpected exception caught: " +

                object outputObject = xmlTransform.GetOutput();

    // Create an XML document with Element and Text nodes. 
    private static XmlDocument LoadXMLDoc()
        XmlDocument xmlDoc = new XmlDocument();

        XmlNode mainNode = xmlDoc.CreateNode(

        XmlNode textNode = xmlDoc.CreateTextNode("Some text to encode.");

        Console.WriteLine("Created the following XML Document for " +
            "transformation: ");
        return xmlDoc;

    // Resolve the specified base and relative Uri's . 
    private static Uri ResolveUris(Uri baseUri, string relativeUri)
        XmlUrlResolver xmlResolver = new XmlUrlResolver();
        xmlResolver.Credentials = 

        XmlDsigBase64Transform xmlTransform = new XmlDsigBase64Transform();
        xmlTransform.Resolver = xmlResolver;

        Uri absoluteUri = xmlResolver.ResolveUri(baseUri, relativeUri);

        if (absoluteUri != null)
                "Resolved the base Uri and relative Uri to the following:");
                "Unable to resolve the base Uri and relative Uri");
        return absoluteUri;
// This sample produces the following output: 
// Created the following XML Document for transformation: 
// <ContosoMessages xmlns="">Some text to encode.
// </ContosoMessages> 
// Xml representation of the current transform: 
// <Transform Algorithm="" xmlns=
// "" />
// Encoding the following message: Some text to encode. 
// Message encoded: Jmr^ 
// Resolved the base Uri and relative Uri to the following: 
// This sample completed successfully; press Enter to exit.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0