Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DatingAppContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(builder =>
                {
                    builder.Run(async handler =>
                    {
                        handler.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                        var error = handler.Features.Get <IExceptionHandlerFeature>();
                        if (error != null)
                        {
                            handler.Response.AddApplicationError(error.Error.Message);
                            await handler.Response.WriteAsync(error.Error.Message);
                        }
                    });
                });
                app.UseHsts();
            }

            context.SeedData(); //SEED

            app.UseCors(o => o.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseAuthentication();

            app.UseHttpsRedirection();
            app.UseMvc();
        }