Startup.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.Extensions.Configuration;
  5. using Microsoft.Extensions.DependencyInjection;
  6. namespace FspWebApp
  7. {
  8. public class Startup
  9. {
  10. public Startup(IConfiguration configuration)
  11. {
  12. Configuration = configuration;
  13. }
  14. public IConfiguration Configuration { get; }
  15. // This method gets called by the runtime. Use this method to add services to the container.
  16. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
  17. public void ConfigureServices(IServiceCollection services)
  18. {
  19. services.AddCors(options => options.AddPolicy("cors", builder => builder.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin()));
  20. services.AddMvc(setupAction => setupAction.EnableEndpointRouting = false);
  21. services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
  22. }
  23. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  24. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  25. {
  26. //if (env.IsDevelopment())
  27. //{
  28. // app.UseDeveloperExceptionPage();
  29. //}
  30. app.UseCors("cors");
  31. app.UseMvc();
  32. }
  33. }
  34. }