A SAML authn request was expected. Instead samlp:Response was received

I am acting as an SSO initiated Service Provider. I have configured a LocalServiceProviderConfiguration and multiple PartnerIdentityProviderConfigurations. I am successfully making the InitiateSsoAsync call to the identity provider. When that is complete and succesful, the service provider is getting called (via SAML controller / AssertionConsumerService). However, in the AssertionConsumerService when I execute ReceiveSsoAsync() in the service provider, I am getting an error that the “A SAML authn request was expected. Instead samlp:Response was received.”. I don’t understand why I am getting this message since my service provider would not need to have a local identity provider. Can you give me an idea what the problem might be?
this is the below code i wrote

public async Task InitiateSingleSignOn()
{
// Get the name of the logged in user.
var userName = User?.Identity?.Name;

 // For demonstration purposes, include some claims.
 var attributes = new List<SamlAttribute>()
 {
     new SamlAttribute(ClaimTypes.Email, User?.FindFirst(ClaimTypes.Email)?.Value),
     new SamlAttribute(ClaimTypes.GivenName, User?.FindFirst(ClaimTypes.GivenName)?.Value),
     new SamlAttribute(ClaimTypes.Surname, User?.FindFirst(ClaimTypes.Surname)?.Value),
     new SamlAttribute("PrimarySid", "10554"),
     new SamlAttribute("Name", "civicuser")
 };

 var partnerName = _configuration["PartnerName"];
 var relayState = _configuration["RelayState"];
 var authnContext = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport";
 // Initiate single sign-on to the service provider (IdP-initiated SSO)
 // by sending a SAML response containing a SAML assertion to the SP.
 // The optional relay state normally specifies the target URL once SSO completes.
 await _samlIdentityProvider.InitiateSsoAsync(partnerName, userName, attributes, relayState);
 return new EmptyResult();

}

await _isamlIdentityProvider.ReceiveSsoAsync();

It sounds like you’re calling ISamlIdentityProvider.ReceiveSsoAsync instead of ISamlServiceProvider.ReceiveSsoAsync.

Also, the code you included is for an identity provider but you’re acting as the service provider.

I suggest taking a look at the ExampleServiceProvider project under the Examples\SSO folder. The SamlController demonstrates calling ISamlServiceProvider.InitiateSsoAsync to create and send a SAML authn request to the specified partner identity provider. It calls ISamlServiceProvider.ReceiveSsoAsync to receive and process the SAML response.