After upgrading from ComponentSpace.Saml2 6.2.0 to 6.3.0, we are receiving the following error when beginning a SAML2 sign in flow:
System.InvalidOperationException: Headers are read-only, response has already started.
Here’s the call stack:
ComponentSpace.Saml2.SamlServiceProvider[100]
Initiation of SSO to the partner identity provider has failed.
System.InvalidOperationException: Headers are read-only, response has already started.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_SetCookie(StringValues value)
at Microsoft.AspNetCore.Http.ResponseCookies.Append(String key, String value, CookieOptions options)
at ComponentSpace.Saml2.Bindings.AspNetHttpResponse.AddCookie(String cookieName, String cookieValue, CookieOptions cookieOptions)
at ComponentSpace.Saml2.Session.CookieSsoSessionStore.AddCookie(String cookieName, String cookieValue, CookieOptions cookieOptions)
at ComponentSpace.Saml2.Session.CookieSsoSessionStore.SaveAsync(Object ssoSession)
at ComponentSpace.Saml2.SamlProvider.SaveSamlStateAsync()
at ComponentSpace.Saml2.SamlServiceProvider.InitiateSsoAsync(String partnerName, String relayState, ISsoOptions ssoOptions)