Specifying other variables for HttpPostFormOptions during run time

In version 2.9.0 of SAML for ASP .NET Core that I’m currently using and trying to upgrade from, I was able to override OtherFormVariables dictionary and provide my own form variables during HTTP post. In v4.3.0, OtherFormVariables is no longer public and I can’t override. The only way to specify my own variables is during HttpPostForm configuration, but that doesn’t help in my business scenario, since I need to set the variable later in the process. The only way I was able to do it is to use reflection and get private httpPostFormOptions variable and set httpPostFormOptions.OtherFormVariables when I override public override HttpPostFormContent Create(string url, string messageFormVariableName, string messageFormVariableValue,
string relayStateFormVariableName, string relayStateFormVariableValue) method.

This is really something I would like to avoid, but I can’t find any other solutions.

Other form variables may be set as follows:

using ComponentSpace.Saml2.Bindings.Post;

builder.Services.Configure<HttpPostFormOptions>(options =>
{
    options.OtherFormVariables = new Dictionary<string, string>
    {
        { "name1", "value1" },
        { "name2", "value2" }
    };
});

Are you after something more dynamic?

Yes, I need it to be dynamic. Basically, I need it to be set after I get some information from the database during initiate SSO login process.

Ok. This is something we will look to add in the next release.

You’re welcome to contact us by email if you’d like to be notified when it’s ready for beta testing.

Excellent. Will look for that feature in the next release then.