private void HandleRequestAuthenticationCompleted(object userState)
        {
            AuthorizationAsyncResult result = (AuthorizationAsyncResult)userState;

            if (!result.CancellationRequested)
            {
                if (Authorization.Authorize(result.LoadResult.LoadedContent) == AuthorizationResult.Allowed)
                {
                    // Direct the user to the requested page
                    result.Complete();
                }
                else
                {
                    // If the user is still not authorized, he needs to be redirected
                    result.LoadResult = new LoadResult(this.DefaultSource);
                    result.Complete();
                }
            }
        }
        private void HandleLoadCompleted(IAsyncResult asyncResult)
        {
            AuthorizationAsyncResult result = (AuthorizationAsyncResult)asyncResult.AsyncState;

            if (!result.CancellationRequested)
            {
                try
                {
                    result.LoadResult = this._loader.EndLoad(result.InnerAsyncResult);
                    AuthorizationNavigationMode navigationMode = this.GetContentNavigationMode(result.LoadResult.LoadedContent);

                    if (Authorization.Authorize(result.LoadResult.LoadedContent) == AuthorizationResult.Allowed)
                    {
                        // Direct the user to the requested page
                        result.Complete();
                    }
                    else if (WebContextBase.Current.Authentication.User.Identity.IsAuthenticated ||
                             (navigationMode == AuthorizationNavigationMode.Redirect))
                    {
                        // If the user is authenticated but not authorized, he needs to be redirected
                        result.LoadResult = new LoadResult(this.DefaultSource);
                        result.Complete();
                    }
                    else if (navigationMode == AuthorizationNavigationMode.Prompt)
                    {
                        if (Authorization.Prompter == null)
                        {
                            throw new InvalidOperationException("Authorization.Prompter cannot be null when the navigationMode is 'Prompt'.");
                        }
                        // If the user is not authenticated, we need to prompt for re-authentication or redirect
                        Authorization.Prompter.RequestAuthentication(this.HandleRequestAuthenticationCompleted, result);
                    }
                }
                catch (InvalidOperationException ex)
                {
                    result.Error = ex;
                    result.Complete();
                }
            }
        }