SAML InitiateSSO via ajax call.

I am using MVC.NET and ajax for I have the following code in an html file to call the controller action:

$.ajax({
url: “/SAML”,
type: ‘POST’,
beforeSend: function (xhr) {
xhr.setRequestHeader(“Authorization”, "Bearer " + authToken);
},

crossDomain: true,
success: function (data) {
console.log(data);
}
});

I have the following “SAML” controller action:

[ActionName(“SAML”)]
[AcceptVerbs(“GET”, “POST”, “OPTIONS”)]
public void SAML()
{
SAMLController.SSOSessionStore = new DatabaseSSOSessionStore(“System.Data.SqlClient”, connString, “SAML_SSO_Sessions”);

SAMLIdentityProvider.InitiateSSO(
System.Web.HttpContext.Current.Response,
userName,
attributes,
targetUrl,
partnerSP);
}

I am successfully able to get the response back from the provider. I see the HTML data that is returned to do the auto form post to the provider in the log files.

In this situation, how would I get that “form html” data back to the html page making the ajax call so that the user is redirected to the third party site?

Thanks,

SAML SSO is a browser based protocol.
Our recommendation is to not do this via an Ajax call.
Instead, initiate SAML SSO via the browser and allow the browser to process the HTML form and send the SAML response in an HTTP Post to the service provider.