How do set IdentityResult?

asp.net-identity, usermanager

Solution

`IdentityResult` takes an `IEnumerable<String>` in the constructor:

public IdentityResult(IEnumerable<string> errors)

These are the errors that will be passed back to the calling code.

Alternatively you can call this method:

var identityResult = IdentityResult.Failed("First error", "Second validation error");

This will be identical to the calling the constructor with list of strings.

Problem

I'm in a situation where I need to validate a new (or updating) users' email address using some more complex rules. I thought of using the User store that goes into the user manager but where and how does the IdentityResult get constructed? Do I just throw an exception and that's it? Or is there some extra validation mechanism?

Original source