Startup.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using JwtTest.Jwt;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.AspNetCore.Hosting;
  8. using Microsoft.AspNetCore.HttpsPolicy;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.Configuration;
  11. using Microsoft.Extensions.DependencyInjection;
  12. using Microsoft.Extensions.Hosting;
  13. using Microsoft.Extensions.Logging;
  14. namespace JwtTest
  15. {
  16. public class Startup
  17. {
  18. public Startup(IConfiguration configuration)
  19. {
  20. Configuration = configuration;
  21. }
  22. public IConfiguration Configuration { get; }
  23. // This method gets called by the runtime. Use this method to add services to the container.
  24. public void ConfigureServices(IServiceCollection services)
  25. {
  26. services.AddControllers();
  27. //jwtÊÚȨÑéÖ¤
  28. services.AddAuthorizationSetup();
  29. }
  30. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  31. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  32. {
  33. if (env.IsDevelopment())
  34. {
  35. app.UseDeveloperExceptionPage();
  36. }
  37. app.UseHttpsRedirection();
  38. app.UseRouting();
  39. app.UseAuthentication();
  40. app.UseAuthorization();
  41. app.UseEndpoints(endpoints =>
  42. {
  43. endpoints.MapControllers();
  44. });
  45. }
  46. }
  47. }