裕隆城折扣合作@中興低碳 折扣報表
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 месеца
преди 1 месец
преди 3 месеца
преди 1 месец
преди 3 месеца
преди 1 месец
преди 3 месеца
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using CouponReport.Models.CouponMiddleware;
  2. using CouponReport.Models.Parkingeyes;
  3. using CouponReport.Service;
  4. using LaneFlowReport.Auth;
  5. using LaneFlowReport.Options;
  6. using Microsoft.AspNetCore.Authentication.Cookies;
  7. using Microsoft.EntityFrameworkCore;
  8. var builder = WebApplication.CreateBuilder(args);
  9. builder.Services.AddHttpClient();
  10. builder.Services.AddScoped<ReportService>();
  11. builder.Services.AddSingleton<ParkingAuthProvider>();
  12. builder.Services.Configure<OauthOption>(builder.Configuration.GetSection("Authentication:Parking"));
  13. builder.Services.AddDbContext<CouponMiddlewareContext>(options =>
  14. options.UseSqlServer(builder.Configuration.GetConnectionString("myConnection")));
  15. builder.Services.AddDbContext<ParkingEyesContext>(options =>
  16. options.UseSqlServer(builder.Configuration.GetConnectionString("ParkingEyesConnection")));
  17. builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
  18. .AddCookie(options =>
  19. {
  20. options.LoginPath = "/Home/Index";
  21. options.AccessDeniedPath = "/Home/Index";
  22. options.Cookie.Name = "CouponReport.Auth"; // 設定 Cookie 名稱
  23. options.Cookie.HttpOnly = true;
  24. options.Cookie.IsEssential = true;
  25. options.Cookie.SameSite = SameSiteMode.Strict;
  26. options.SlidingExpiration = true;
  27. options.ExpireTimeSpan = TimeSpan.FromMinutes(15); // 設定15分鐘後過期
  28. });
  29. // Add services to the container.
  30. builder.Services.AddControllersWithViews();
  31. builder.Services.AddSession(options =>
  32. {
  33. options.Cookie.HttpOnly = true;
  34. options.Cookie.IsEssential = true;
  35. options.IdleTimeout = TimeSpan.FromMinutes(15); // Session 15分鐘後過期
  36. });
  37. var app = builder.Build();
  38. // Configure the HTTP request pipeline.
  39. if (!app.Environment.IsDevelopment())
  40. {
  41. app.UseExceptionHandler("/Home/Error");
  42. app.UseHsts();
  43. }
  44. app.UseHttpsRedirection();
  45. app.UseStaticFiles();
  46. app.UseRouting();
  47. app.UseSession();
  48. app.UseAuthentication();
  49. app.UseAuthorization();
  50. app.MapControllerRoute(
  51. name: "default",
  52. pattern: "{controller=Home}/{action=Index}/{id?}");
  53. app.Run();