// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); //c.RoutePrefix = string.Empty; }); app.UseHttpsRedirection(); quotesDbContext.Database.EnsureCreated(); app.UseResponseCaching(); // 2. Enable authentication middleware app.UseAuthentication(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } //dbContext.Database.EnsureCreated(); app.UseResponseCaching(); // 2. Enable authentication middleware app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseHttpsRedirection(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); quotesDbContext.Database.EnsureCreated(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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(); //quotesDbContext.Database.EnsureCreated(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseResponseCaching(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, QuotesDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //dbContext.Database.EnsureCreated(); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); // This is to tell the program that to create the database if not found // quotesDbContext.Database.EnsureCreated(); //quotesDbContext.Database.Migrate(); // this is used to update the migration runtime app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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.UseExceptionHandler("/api/errors/500"); // Handles non - success status codes with empty body //app.UseStatusCodePagesWithReExecute("/api/errors/{0}"); // to handle http status code errors like 404 (not found) 500 (internal sever error) //quotesDbContext.Database.EnsureCreated(); // use this when you are sure that once database created will never changed. app.UseHttpsRedirection(); app.ConfigureCustomExceptionMiddleware(); app.UseResponseCaching(); app.UseAuthentication(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, QuotesDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); //If db doesn't exist it gets created. It is useful if our schema will not change. //if your schem changes you need migration dbContext.Database.EnsureCreated(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, QuotesDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // 2. Enable authentication middleware app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); //app.UseEndpoints(routes => //{ // routes.MapRazorPages(); // routes.MapFallbackToPage("_Host"); //}); //If db doesn't exist it gets created. It is useful if our schema will not change. //if your schem changes you need migration dbContext.Database.EnsureCreated(); //Caching app.UseResponseCaching(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, QuotesDbContext quotesDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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(); //quotesDbContext.Database.Migrate(); app.UseResponseCaching(); app.UseAuthentication(); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Swagger Sample"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public static void Configure(IApplicationBuilder app, IWebHostEnvironment env, QuotesDbContext quotesDbContext) { //quotesDbContext.Database.EnsureCreated(); //quotesDbContext.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseResponseCaching(); // 2. Enable authentication middleware app.UseAuthentication(); quotesDbContext.Database.EnsureCreated(); }