title: DELETE return ERROR 405(Method Not allowed) I'm using React and ASP.Net Core
body: <p>I am attempting to delete a row by using the id on the row. when I Execute it on Local server, it worked correctly,but on plesk server have an error.
  Requests CREATE and GET worked correctly but for DELETE and UPDATE not work.</p>
  <blockquote>
  <p>function DELETE:</p>
  </blockquote>
  <pre><code>onDeleteConfirmation(e) {
      e.preventDefault();
      const { id } = this.props.match.params;
  
      axios.delete(&quot;api/Trips/DeleteTrip/&quot; + id).then(result =&gt; {
          this.props.history.push('/Trips')
      });
  }
  </code></pre>
  <blockquote>
  <p>funtion UPDATE:</p>
  </blockquote>
  <pre><code>onUpdateConfirmation(e) {
      e.preventDefault();
      const { id } = this.props.match.params;
      let tripObject = {
          name: this.state.name,
          description: this.state.description,
          dateStarted: this.state.dateStarted,
          dateComplated: this.state.dateComplated
      }
      axios.put(&quot;api/Trips/UpdateTrip/&quot;+id, tripObject).then(result =&gt; {
          this.props.history.push('/Trips')
      });
  }
  </code></pre>
  <blockquote>
  <p>Controller Service:</p>
  </blockquote>
  <pre><code>[HttpDelete(&quot;DeleteTrip/{id}&quot;)]
      public IActionResult DeleteTrip(int id)
      {
          _service.DeleteTrip(id);
          return Ok();
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0lURK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0lURK.png" alt="enter image description here" /></a>
  .
  I use ASP.Net Core 3 and React in visual stdio.
  my proble accure when I try to execute at online server Plesk.</p>
  <blockquote>
  <p>This is Full controller:</p>
  </blockquote>
  <pre><code>    using Microsoft.AspNetCore.Cors;
      using Microsoft.AspNetCore.Http;
      using Microsoft.AspNetCore.Mvc;
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Threading.Tasks;
      using Trips.Data.Models;
      using Trips.Data.Services;
  
  namespace Trips.Controllers
  {
      [Route(&quot;api/[controller]&quot;)]
      [ApiController]
      public class TripsController : ControllerBase
      {
          public ITripService _service { get; set; }
  
          public TripsController(ITripService service)
          {
              _service = service;
          }
  
          [EnableCors(&quot;AnotherPolicy&quot;)]
          [HttpGet(&quot;GetTrips&quot;)]
          public IActionResult GetTrips()
          {
              try
              {
                  //throw new Exception();
                  var allTrips = _service.GetAllTrips();
                  return Ok(allTrips);
              }
              catch (Exception ex)
              {
                  return BadRequest(ex.Message);
              }
  
          }
  
          [EnableCors(&quot;AnotherPolicy&quot;)]
          [HttpGet(&quot;SingleTrip/{id}&quot;)]
          public IActionResult GetTripById(int id)
          {
              var trip = _service.GetTripById(id);
              return Ok(trip);
          }
  
          [EnableCors(&quot;AnotherPolicy&quot;)]
          [HttpPost(&quot;AddTrip&quot;)]
          public IActionResult AddTrip([FromBody] Trip trip)
          {
              if (trip != null)
              {
                  _service.AddTrip(trip);
              }
              return Ok();
          }
  
          [EnableCors(&quot;AnotherPolicy&quot;)]
          [HttpPut(&quot;UpdateTrip/{id}&quot;)]
          public IActionResult UpdateTrip(int id, [FromBody] Trip trip)
          {
              _service.UpdateTrip(id, trip);
              return Ok(trip);
          }
  
          [EnableCors(&quot;AnotherPolicy&quot;)]
          [HttpDelete(&quot;DeleteTrip/{id}&quot;)]
          public IActionResult DeleteTrip(int id)
          {
              _service.DeleteTrip(id);
              return Ok();
          }
  
      }
  }
  </code></pre>
  <p>.</p>
  <blockquote>
  <p>StartUp.cs</p>
  </blockquote>
  <pre><code>public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
  
              services.AddControllersWithViews();
  
              // In production, the React files will be served from this directory
              services.AddSpaStaticFiles(configuration =&gt;
              {
                  configuration.RootPath = &quot;ClientApp/build&quot;;
              });
  
              // 
              services.AddTransient&lt;ITripService, TripService&gt;();
  
              services.AddCors(options =&gt;
              {
                  options.AddPolicy(&quot;AnotherPolicy&quot;,
                      builder =&gt;
                      {
                          builder.WithOrigins(
                                  &quot;http://hirkansolar.ir/&quot;,
                                  &quot;http://react.hirkansolar.ir/&quot;
              )
              .AllowAnyHeader()
              .WithMethods(&quot;PUT&quot;, &quot;DELETE&quot;, &quot;GET&quot;, &quot;POST&quot;);
                      });
              });
  
          }
  
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Error&quot;);
                  app.UseHsts();
              }
  
              app.UseStaticFiles();
              app.UseSpaStaticFiles();
  
              app.UseRouting();
  
              // ----
              app.UseCors();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllerRoute(
                      name: &quot;default&quot;,
                      pattern: &quot;{controller}/{action=Index}/{id?}&quot;);
              });
  
              app.UseSpa(spa =&gt;
              {
                  spa.Options.SourcePath = &quot;ClientApp&quot;;
  
                  if (env.IsDevelopment())
                  {
                      spa.UseReactDevelopmentServer(npmScript: &quot;start&quot;);
                  }
              });
          }
      }
  </code></pre>