public void Init(HttpApplication context) {

            MasterEntities entitiesCtx = new MasterEntities();
            IEntityRepository<Tenant, Guid> tenantRepository = new EntityRepository<Tenant, Guid>(entitiesCtx);
            try {
                ValidateRequest(new HttpContextWrapper(context.Context), tenantRepository);
            }
            catch (HttpException) // will throw at the app start-up
            { 
            }
        }
        protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) {

            HttpContextBase httpContext = request.Properties["MS_HttpContext"] as HttpContextBase;
            MasterEntities entitiesCtx = new MasterEntities();
            IEntityRepository<Tenant, Guid> tenantRepository = new EntityRepository<Tenant, Guid>(entitiesCtx);

            ValidateRequest(httpContext, tenantRepository);

            var tenant = httpContext.Items["App:Tenant"] as string;
            if (tenant == null) {

                return Task.FromResult(request.CreateResponse(HttpStatusCode.NotFound));
            }

            return base.SendAsync(request, cancellationToken);
        }