Skip to content

Update hosted-with-identity-server.md#20117

Merged
guardrex merged 2 commits intodotnet:masterfrom
chassq:patch-1
Oct 6, 2020
Merged

Update hosted-with-identity-server.md#20117
guardrex merged 2 commits intodotnet:masterfrom
chassq:patch-1

Conversation

@chassq
Copy link
Copy Markdown

@chassq chassq commented Oct 6, 2020

[EDIT by guardrex to add the fixes]

Fixes #19935

The code identity.RemoveClaim(existingClaim); was throwing an exception that the collection was being altered. When I commented that line of code out everything was fine but claims were not being removed. The modification above creates a separate list so as not to involve the Claims collection on User.Identity.

The code identity.RemoveClaim(existingClaim); was throwing an exception that the collection was being altered. When I commented that line of code out everything was fine but claims were not being removed. The modification above creates a separate list so as not to involve the Claims collection on User.Identity.
@guardrex
Copy link
Copy Markdown
Collaborator

guardrex commented Oct 6, 2020

@chassq ... This is a duplicate of #19935 and will be addressed for the .NET 5 content on #19503.

@guardrex
Copy link
Copy Markdown
Collaborator

guardrex commented Oct 6, 2020

🤔 The code doesn't throw on 3.x, and I was going to fix it for .NET 5 updates ... however ... 🤔 ... let's go ahead with a harmless update to 3.x code in case others try and use this with 5.0 preview. Let's go with @Frankofoedu's solution that just makes a new array from the enumerable. I'll make the modification to this PR for it.

@guardrex guardrex reopened this Oct 6, 2020
@guardrex
Copy link
Copy Markdown
Collaborator

guardrex commented Oct 6, 2020

Thanks @chassq 🚀 and @Frankofoedu 🌴.

@guardrex guardrex merged commit 26b2362 into dotnet:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't change a collection while iterating

2 participants