Saml2SecurityTokenHandler.WriteAssertion Method (XmlWriter, Saml2Assertion)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Serializes the specified SAML assertion to the specified XML writer.

Namespace:   System.IdentityModel.Tokens
Assembly:  System.IdentityModel (in System.IdentityModel.dll)

protected virtual void WriteAssertion(
	XmlWriter writer,
	Saml2Assertion data


Type: System.Xml.XmlWriter

The XmlWriter to use for the serialization.

Type: System.IdentityModel.Tokens.Saml2Assertion

A Saml2Assertion that represents the assertion to serialize.

Exception Condition

writer is null.


data is null.


The assertion specified by data has both the EncryptingCredentials and T:System.IdentityModel.Tokens.Saml2SecurityTokenHandler.ReceivedEncryptingCredentials properties set to null.


There are no statements and no subject in the assertion specified by data. (Both the Subject property and the Statements property are null.) If an assertion does not contain statements, it must contain a subject.


The assertion specified by data contains an authentication, attribute, or authorization decision statement and no subject—these statements require a subject. (The Statements property contains a statement of type Saml2AttributeStatement, Saml2AuthenticationStatement, or Saml2AuthorizationDecisionStatement and the Subject property is null).


The token encrypting credentials do not have a Symmetric Key specified.

.NET Framework
Available since 4.5
Return to top