Program.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Id4;
  2. var builder = WebApplication.CreateBuilder(args);
  3. var services = builder.Services;
  4. // Add services to the container.
  5. builder.Services.AddControllersWithViews();
  6. services.AddIdentityServer(options =>
  7. {
  8. options.Events.RaiseErrorEvents = true;
  9. options.Events.RaiseInformationEvents = true;
  10. options.Events.RaiseFailureEvents = true;
  11. options.Events.RaiseSuccessEvents = true;
  12. })
  13. // in-memory, code config
  14. .AddTestUsers(InMemoryConfig.Users().ToList())
  15. .AddInMemoryApiResources(InMemoryConfig.GetApiResources())
  16. .AddInMemoryClients(InMemoryConfig.GetClients())
  17. .AddInMemoryApiScopes(InMemoryConfig.ApiScopes)
  18. .AddDeveloperSigningCredential();
  19. services.AddAuthentication();//ÅäÖÃÈÏÖ¤·þÎñ
  20. var app = builder.Build();
  21. // Configure the HTTP request pipeline.
  22. if (!app.Environment.IsDevelopment())
  23. {
  24. app.UseExceptionHandler("/Home/Error");
  25. }
  26. app.UseStaticFiles();
  27. app.UseRouting();
  28. app.UseIdentityServer();
  29. app.UseAuthorization();
  30. app.MapControllerRoute(
  31. name: "default",
  32. pattern: "{controller=Home}/{action=Index}/{id?}");
  33. app.Run();