Created
July 31, 2014 09:48
-
-
Save lski/ae5c69c2d2d596b28f5e to your computer and use it in GitHub Desktop.
An additional extension method for attempting to get the Guid out of a claims identity object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Principal; | |
namespace Microsoft.AspNet.Identity { | |
public static class IIdentityExt { | |
public static Guid GetGuid(this IIdentity identity) { | |
var result = Guid.Empty; | |
string id = identity.GetUserId(); | |
Guid.TryParse(id, out result); | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment