title: Web Application Cors .NET CORE 3.1 vs 2.1
body: <p>Recently I have been switching slowly over to .NET CORE 3.1 for everything I do, but when I was trying to port some of my Web Application (Restful API) I ran into issues with Cors.</p>
  
  <p>Code from project running .NET CORE 2.1:</p>
  
  <pre><code>        public void ConfigureServices(IServiceCollection services)
          {
              services.AddCors(options =&gt;
              {
                  options.AddPolicy("AllowAnyOrigin",
                  builder =&gt; builder
                      .AllowAnyOrigin()
                      .AllowAnyMethod()
                      .AllowAnyHeader());
              });
  
              services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseHsts();
              }
  
              app.UseCors("AllowAnyOrigin");
  
              app.UseHttpsRedirection();
  
              app.UseMvc();
          }
  </code></pre>
  
  <p>Code from project running .NET CORE 3.1:</p>
  
  <pre><code>        public void ConfigureServices(IServiceCollection services)
          {
              services.AddControllers();
  
              services.AddCors(options =&gt;
              {
                  options.AddPolicy("AllowAnyOrigin",
                  builder =&gt; builder
                      .AllowAnyOrigin()
                      .AllowAnyMethod()
                      .AllowAnyHeader());
              });
  
              services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseHsts();
              }
  
              app.UseCors("AllowAnyOrigin");
  
              app.UseHttpsRedirection();
  
              app.UseRouting();
  
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllers();
              });
          }
  </code></pre>
  
  <p>When I make a request to the API running 2.1 everything goes as expected, but if I try to make the same request to the API running 3.1 I get a 405 error (Method Not Allowed Error).</p>
  
  <p>Has anyone else run into this issue, if so what is the solution to it?</p>