コード例 #1
0
        public async Task <IActionResult> StoreAnonymousIdentifier()
        {
            if ((await loginHandler.LoggedInUserIdAsync(HttpContext)).HasValue || HttpContext.Session.GetString("anonymousIdentifier") != null)
            {
                return(Json(new { success = true }));
            }

            HttpContext.Session.SetString("anonymousIdentifier", randomProvider.RandomString(12));
            return(Json(new { success = true }));
        }
コード例 #2
0
        public async Task <string> GenerateIdAsync()
        {
            bool   okay;
            string generated;

            do
            {
                generated = randomProvider.RandomString(8).ToLowerInvariant();
                okay      = await GetAsync(generated) == null;
            } while (!okay);
            return(generated);
        }
コード例 #3
0
        public string GenerateId()
        {
            bool   okay;
            string generated;

            do
            {
                generated = randomProvider.RandomString(8).ToLowerInvariant();
                okay      = Get(generated) == null;
            } while (!okay);
            return(generated);
        }