Program.cs 912 B

1234567891011121314151617181920212223242526272829303132333435
  1. using Microsoft.Data.SqlClient;
  2. using Microsoft.EntityFrameworkCore;
  3. using ShoeShopMvc.Models;
  4. var builder = WebApplication.CreateBuilder(args);
  5. // Add services to the container.
  6. builder.Services.AddControllersWithViews();
  7. builder.Services.AddDbContext<ShoeShopContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("ShoeShopDb")));
  8. builder.Services.AddSession();
  9. var app = builder.Build();
  10. // Configure the HTTP request pipeline.
  11. if (!app.Environment.IsDevelopment())
  12. {
  13. app.UseExceptionHandler("/Home/Error");
  14. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  15. app.UseHsts();
  16. }
  17. app.UseHttpsRedirection();
  18. app.UseStaticFiles();
  19. app.UseRouting();
  20. app.UseAuthorization();
  21. app.MapControllerRoute(
  22. name: "default",
  23. pattern: "{controller=Orders}/{action=Index}/{id?}");
  24. app.Run();