SamlSecurityTokenHandler.WriteAssertion Method (XmlWriter, SamlAssertion)

.NET Framework (current version)

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,
	SamlAssertion assertion


Type: System.Xml.XmlWriter

The XmlWriter to use for the serialization.

Type: System.IdentityModel.Tokens.SamlAssertion

A SamlAssertion that represents the assertion to serialize.

Exception Condition

writer is null.


assertion is null.


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


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


The assertion specified by assertion contains an authentication, attribute, or authorization decision statement and no subject—these statements require a subject. (The Statements property contains a statement of type SamlAttributeStatement, SamlAuthenticationStatement, or SamlAuthorizationDecisionStatement and the P:System.IdentityModel.Tokens.SamlAssertion.Subject property is null).


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

.NET Framework
Available since 4.5
Return to top