Use DELETE Method in ASP.NET Core Web API

This project will demonstrate how to Use DELETE Method in ASP.NET Core Web API

  • LearnASPNETCoreWebAPIWithRealApps
    • Controllers
      • ProductController.cs
    • Startup.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LearnASPNETCoreWebAPIWithRealApps.Controllers
{
    [Route("api/product")]
    public class ProductController : Controller
    {
        [HttpDelete("delete/{id}")]
        public async Task<IActionResult> Delete(string id)
        {
            try
            {
                Debug.WriteLine("Id is deleted: " + id);
                return Ok();
            }
            catch
            {
                return BadRequest();
            }
        }

    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

namespace LearnASPNETCoreWebAPIWithRealApps
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
        }

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
        }
    }
}

Screenshots