Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            // Add our dependencies
            DependencyResolver.AddBindings(services);

            services.Configure <CookieTempDataProviderOptions>(options => {
                options.Cookie.IsEssential = true;
            });

            // Dependency injection middleware
            if (HostingEnvironment.IsProduction())
            {
                services.AddSingleton <IUtilities>(s => new Utilities(true));
            }
            else
            {
                services.AddSingleton <IUtilities>(s => new Utilities(false));
            }

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }