示例#1
0
        public async Task <ActionResult> Create([Bind("Title,Owner")] Todo todo)
        {
            try
            {
                await _todoListService.AddAsync(todo);
            }
            catch (WebApiMsalUiRequiredException hex)
            {
                // Challenges the user if exception is thrown from Web API.
                try
                {
                    var claimChallenge = ExtractAuthenticationHeader.ExtractHeaderValues(hex);
                    _consentHandler.ChallengeUser(new string[] { "user.read" }, claimChallenge);

                    return(new EmptyResult());
                }
                catch (Exception ex)
                {
                    _consentHandler.HandleException(ex);
                }

                Console.WriteLine(hex.Message);
            }
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create([Bind("Title,Owner")] Todo todo)
        {
            await _todoListService.AddAsync(todo);

            return(RedirectToAction("Index"));
        }