public async Task InvokeAsync(HttpContext context, RequestDelegate next)
        {
            var tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult : true);

            if (tenant?.Id != _currentTenant.Id)
            {
                using (_currentTenant.Change(tenant?.Id, tenant?.Name))
                {
                    var requestCulture = await TryGetRequestCultureAsync(context);

                    if (requestCulture != null)
                    {
                        CultureInfo.CurrentCulture   = requestCulture.Culture;
                        CultureInfo.CurrentUICulture = requestCulture.UICulture;
                        AbpRequestCultureCookieHelper.SetCultureCookie(
                            context,
                            requestCulture
                            );
                    }

                    await next(context);
                }
            }
            else
            {
                await next(context);
            }
        }
Exemple #2
0
        public async Task InvokeAsync(HttpContext context, RequestDelegate next)
        {
            var tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult : true);

            using (_currentTenant.Change(tenant?.Id, tenant?.Name))
            {
                await next(context);
            }
        }
Exemple #3
0
    public async Task InvokeAsync(HttpContext context, RequestDelegate next)
    {
        TenantConfiguration tenant = null;

        try
        {
            tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult : true);
        }
        catch (Exception e)
        {
            if (await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e))
            {
                return;
            }
        }

        if (tenant?.Id != _currentTenant.Id)
        {
            using (_currentTenant.Change(tenant?.Id, tenant?.Name))
            {
                if (_tenantResolveResultAccessor.Result != null &&
                    _tenantResolveResultAccessor.Result.AppliedResolvers.Contains(QueryStringTenantResolveContributor.ContributorName))
                {
                    AbpMultiTenancyCookieHelper.SetTenantCookie(context, _currentTenant.Id, _options.TenantKey);
                }

                var requestCulture = await TryGetRequestCultureAsync(context);

                if (requestCulture != null)
                {
                    CultureInfo.CurrentCulture   = requestCulture.Culture;
                    CultureInfo.CurrentUICulture = requestCulture.UICulture;
                    AbpRequestCultureCookieHelper.SetCultureCookie(
                        context,
                        requestCulture
                        );
                    context.Items[AbpRequestLocalizationMiddleware.HttpContextItemName] = true;
                }

                await next(context);
            }
        }
        else
        {
            await next(context);
        }
    }
Exemple #4
0
        public async Task InvokeAsync(HttpContext context, RequestDelegate next)
        {
            TenantConfiguration tenant;

            try
            {
                tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult : true);
            }
            catch (Exception e)
            {
                await _options.MultiTenancyMiddlewareErrorPageBuilder(context, e);

                return;
            }

            if (tenant?.Id != _currentTenant.Id)
            {
                using (_currentTenant.Change(tenant?.Id, tenant?.Name))
                {
                    var requestCulture = await TryGetRequestCultureAsync(context);

                    if (requestCulture != null)
                    {
                        CultureInfo.CurrentCulture   = requestCulture.Culture;
                        CultureInfo.CurrentUICulture = requestCulture.UICulture;
                        AbpRequestCultureCookieHelper.SetCultureCookie(
                            context,
                            requestCulture
                            );
                    }

                    await next(context);
                }
            }
            else
            {
                await next(context);
            }
        }