public class AuthnRequest : RequestAbstractType
Shows how to create an AuthnRequest request and send it over HTTP POST or HTTP Redirect.
using System.Security.Cryptography.X509Certificates; using System.Web; using ComponentPro.Saml2; ... // Create a new instance of the AuthnRequest class. AuthnRequest request = new AuthnRequest(); request.IsPassive = false; // Set Protocol Binding. request.ProtocolBinding = SamlBindingUri.HttpPost; // Set the target provider's Assertion Consumer Service Url. request.AssertionConsumerServiceUrl = "your url"; // Set Issuer request.Issuer = new Issuer(); request.Issuer.NameIdentifier = "your name identifier"; request.NameIdPolicy = new NameIdPolicy(); request.NameIdPolicy.SpNameQualifier = "moodle.sp.myname"; request.NameIdPolicy.AllowCreate = true; request.NameIdPolicy.Format = SamlNameIdentifierFormat.Persistent; request.RequestedAuthnContext = new RequestedAuthnContext(); request.RequestedAuthnContext.Comparison = SamlAuthenticationContextComparison.Exact; request.RequestedAuthnContext.AuthenticationContexts.Add(new AuthnContextClassRef(SamlAuthenticationContext.PasswordProtectedTransport)); // Send the request over HTTP POST request.SendHttpPost(Response, "http://mybaseurl", "my_relay_state"); // Or you can send it over HTTP Redirect // X509Certificate2 certificate = new X509Certificate2("PKey.pfx", "password"); // request.Redirect(Response, "http://mybaseurl", "my_relay_state", certificate.PrivateKey);