예제 #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 => false;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("pt-BR");

            services.AddAuthentication(options =>
            {
                options.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = CookieAuthenticationDefaults.AuthenticationScheme;
            }).AddCookie(options =>
            {
                options.LoginPath        = "/Acesso/Acessar";
                options.AccessDeniedPath = "/Acesso/Acessar";
                options.ExpireTimeSpan   = TimeSpan.FromDays(15);
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            // Seta as urls para lowercase
            services.AddRouting(options => options.LowercaseUrls = true);
            // Registra as dependências
            RegisterContainer.RegisterDependencies(services);
            // Cria uma instância e faz injecção para as toastr
            services.AddScoped <IToastrMensagem, ToastrMensagem>();
        }
예제 #2
0
 public static void Init()
 {
     RegisterContainer.RegisterDependencies();
 }