/// <summary>
 /// To XML Action Result
 /// </summary>
 public static IActionResult ToActionResult(this Saml2Metadata metadata)
 {
     return(new ContentResult
     {
         ContentType = "text/xml",
         Content = metadata.ToXml(),
     });
 }
        public IActionResult Index()
        {
            //var configuration = new Saml2Configuration();

            var entityDescriptor = new EntityDescriptor(_configuration)
            {
                ValidUntil      = 365,
                SPSsoDescriptor = new SPSsoDescriptor
                {
                    WantAssertionsSigned = true,
                    SingleLogoutServices = new[]
                    {
                        new SingleLogoutService
                        {
                            Binding          = ProtocolBindings.HttpPost,
                            Location         = new Uri($"{Request.Scheme}://{Request.Host}{Url.Action("SingleLogout", "Account")}"),
                            ResponseLocation = new Uri($"{Request.Scheme}://{Request.Host}{Url.Action("LoggedOut", "Account")}")
                        }
                    },
                    NameIDFormats = new[]
                    {
                        NameIdentifierFormats.Persistent
                    },
                    AssertionConsumerServices = new[]
                    {
                        new AssertionConsumerService
                        {
                            Binding  = ProtocolBindings.HttpPost,
                            Location = new Uri($"{Request.Scheme}://{Request.Host}{Url.Action("AssertionConsumer", "Account")}")
                        }
                    }
                }
            };

            var metadata = new Saml2Metadata(entityDescriptor);

            return(metadata.CreateMetadata()
                   .ToActionResult());
        }
 protected override void WriteSaml2MetadataAttributes(XmlDictionaryWriter writer, Saml2Metadata metadata)
 {
     base.WriteSaml2MetadataAttributes(writer, metadata);
     writer.WriteXmlnsAttribute(Prefix, Namespace);
 }