Startup.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Hosting;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. namespace WebApi
  11. {
  12. public class Startup
  13. {
  14. public Startup(IConfiguration configuration)
  15. {
  16. Configuration = configuration;
  17. }
  18. public IConfiguration Configuration { get; }
  19. // This method gets called by the runtime. Use this method to add services to the container.
  20. public void ConfigureServices(IServiceCollection services)
  21. {
  22. services.AddRazorPages();
  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. }
  35. app.UseStaticFiles();
  36. app.UseRouting();
  37. app.UseAuthorization();
  38. app.UseEndpoints(endpoints =>
  39. {
  40. endpoints.MapRazorPages();
  41. });
  42. }
  43. }
  44. }