Ejemplo n.º 1
0
        public async Task Invoke(HttpContext context)
        {
            using (RequestServicesContainer.EnsureRequestServices(context, _services))
            {
                AuthenticationHandler <TOptions> handler = CreateHandler();
                await handler.Initialize(Options, context);

                try
                {
                    if (!await handler.InvokeAsync())
                    {
                        await _next(context);
                    }
                }
                catch (Exception)
                {
                    try
                    {
                        handler.Faulted = true;
                        await handler.TeardownAsync();
                    }
                    catch (Exception)
                    {
                        // Don't mask the original exception
                    }
                    throw;
                }
                await handler.TeardownAsync();
            }
        }
        public async Task Invoke(HttpContext context)
        {
            using (RequestServicesContainer.EnsureRequestServices(context, _services))
            {
                AuthenticationHandler <TOptions> handler = CreateHandler();
                await handler.Initialize(Options, context);

                if (!await handler.InvokeAsync())
                {
                    await _next(context);
                }
                await handler.TeardownAsync();
            }
        }