Startup.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.EntityFrameworkCore;
  4. using Microsoft.Extensions.Configuration;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.Hosting;
  7. using WZExport.Data;
  8. namespace WZExport
  9. {
  10. public class Startup
  11. {
  12. public Startup(IConfiguration configuration)
  13. {
  14. Configuration = configuration;
  15. }
  16. public IConfiguration Configuration { get; }
  17. // This method gets called by the runtime. Use this method to add services to the container.
  18. public void ConfigureServices(IServiceCollection services)
  19. {
  20. services.AddRazorPages();
  21. services.AddDbContext<WZContext>(options =>
  22. options.UseMySQL(Configuration.GetConnectionString("WZExportContext")));
  23. }
  24. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  25. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  26. {
  27. if (env.IsDevelopment())
  28. {
  29. app.UseDeveloperExceptionPage();
  30. }
  31. else
  32. {
  33. app.UseExceptionHandler("/Error");
  34. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  35. app.UseHsts();
  36. }
  37. app.UseHttpsRedirection();
  38. app.UseStaticFiles();
  39. app.UseRouting();
  40. app.UseAuthorization();
  41. app.UseEndpoints(endpoints =>
  42. {
  43. endpoints.MapRazorPages();
  44. });
  45. }
  46. }
  47. }