Exemplo n.º 1
0
 public ServicoController(
     IHostingEnvironment hostingEnvironment,
     CompassoDbContext compassoDbContext)
 {
     _hostingEnvironment = hostingEnvironment;
     _compassoDbContext  = compassoDbContext;
 }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ApplicationDbContext dbcontext,
                              CompassoDbContext dbcontext2,
                              UserManager <ApplicationUser> userManager,
                              RoleManager <IdentityRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }


            //policy.WithOrigins("*").AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin();

            app.Use(async(context, next) => {
                await next();
                if (!Path.HasExtension(context.Request.Path.Value) &&
                    context.Response.StatusCode == 404)
                {
                    context.Request.Path = "/index.html";
                    await next();
                }
            });

            // Inicializando o banco de dados com usuários e permissões caso não existam
            // new IdentityInitializer(dbcontext, userManager, roleManager).Initialize();

            app.UseCors(c =>
            {
                c.AllowAnyHeader();
                c.AllowAnyMethod();
                c.AllowAnyOrigin();
                c.AllowCredentials();
            });

            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseMvc();
        }