Startup.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.Extensions.Configuration;
  8. using Microsoft.Extensions.DependencyInjection;
  9. using Microsoft.Extensions.Logging;
  10. using Microsoft.Extensions.Options;
  11. namespace YDSP.Core
  12. {
  13. public class Startup
  14. {
  15. public Startup(IConfiguration configuration)
  16. {
  17. Configuration = configuration;
  18. }
  19. public IConfiguration Configuration { get; }
  20. // This method gets called by the runtime. Use this method to add services to the container.
  21. public void ConfigureServices(IServiceCollection services)
  22. {
  23. services.AddMvc();
  24. services.AddCors(a =>
  25. {
  26. a.AddPolicy("ydsp", policy =>
  27. {
  28. policy.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod().AllowCredentials();
  29. });
  30. });
  31. }
  32. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  33. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  34. {
  35. if (env.IsDevelopment())
  36. {
  37. app.UseDeveloperExceptionPage();
  38. }
  39. app.UseCors("ydsp");
  40. app.UseMvc();
  41. }
  42. }
  43. }