/// <summary> /// since expiry time has now become part of your claims, you now can get it back easily /// this example just returns the remaining time in total seconds, as a string value /// assuming this method is part of your controller methods /// </summary> /// <returns>Get User Identity Expire DateTime</returns> public static string ExpireRemainingTime(this System.Security.Claims.ClaimsIdentity identity) { //var identity = User.Identity as System.Security.Claims.ClaimsIdentity; var claimType = Properties.Settings.Default.LoginExpireClaimType; if (identity != null && identity.HasClaim(c => c.Type == claimType)) { var expireOn = identity.FindFirstValue(claimType); long current = DateTime.Now.Ticks; long?expire = long.Parse(expireOn); long elapsedTicks = (expire ?? 0) - current; TimeSpan elapsedSpan = new TimeSpan(elapsedTicks); var remaining = (int)elapsedSpan.TotalMilliseconds; return(remaining.ToString()); } return(string.Empty); }