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, IWebHostEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors("CorsPolicy"); // actually set the app to use CORS
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            seed.SeedData(20, 1000);

            app.UseMvc(routes => routes.MapRoute(
                           "default", "api/{controller}/{action}/{id?}"
                           ));
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        // IWebHostEnvironment
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors("CorsPolicy");
            }

            seed.SeedData(20, 1000);
            app.UseMvc(routes => routes.MapRoute(
                           "default", "api/{controller}/{action}/{id?}"
                           ));
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            seed.SeedData(20, 1000);
            app.UseHttpsRedirection();
            app.UseCors("AllowMyOrigin").UseMvc();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("CorsPolicy");
            var nCustomers = 20;
            var nOrders    = 1000;

            seeder.SeedData(nCustomers, nOrders);

            app.UseMvc(routes =>
                       routes.MapRoute("default", "api/{controller}/{action}/{id?}")
                       );
        }
Exemplo n.º 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            seed.SeedData(20, 1000); //We want 20 customers and 1000 Orders

            app.UseHttpsRedirection();
            app.UseMvc(routes => routes.MapRoute(
                           "default", "api/{controller}/{action}/{id?}"
                           ));
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors("CorsPolicy");
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            seed.SeedData(20, 1000);
            app.UseMvc(routes => routes.MapRoute(
                           "default", "api/{controller}/{action}/{id?}"
                           ));
        }
Exemplo n.º 7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            seed.SeedData(20, 1000);

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Exemplo n.º 8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors("corsPolicy");
            }

            seed.SeedData(20, 1000);

            //app.UseHttpsRedirection();

            app.UseRouting();

            //app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(name: "default", pattern: "default", "api/{controller}/{action}/{id?}");
            });
        }
Exemplo n.º 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors("CorsPolicy");
            app.UseHttpsRedirection();
            app.UseRouting();
            seed.SeedData(20, 1000);


            //  linie dotyczace zapisywania plikow

            app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions());
            // {
            //    FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Resources")),
            //     RequestPath = new PathString("/Resources")
            // });



            // koniec linii

            // Autoryzacje zabawa
            app.UseAuthentication();
            app.UseAuthorization();
            // Autoryzacje zabawa - koniec
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });


            app.UseOpenApi();
            app.UseSwaggerUi3();
        }
Exemplo n.º 10
0
        //This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                #region Check connection string

                //Check if there's a connection string.
                //var result = string.IsNullOrEmpty(connectionString) ? "Null" : "Not Null";

                //app.Run(async (context) =>
                //{
                //    await context.Response.WriteAsync($"Secret is {result}");
                //});

                #endregion

                //Add Cors policy.
                app.UseCors("CorsPolicy");
            }
            else
            {
                app.UseHsts();
            }

            app.UseCors("CorsPolicy");

            //Seed the database.
            seed.SeedData(NumberOfCustomers, NumberOfOrders);

            //app.UseHttpsRedirection();

            app.UseMvc(routes => routes.MapRoute(
                           "default", "api/{controller}/{action}/{id?}"
                           ));
        }