Skip to content

Instantly share code, notes, and snippets.

@lski
Created July 31, 2014 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lski/ae5c69c2d2d596b28f5e to your computer and use it in GitHub Desktop.
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
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