Hello all,
Firstly, the topic is related to WebAPI but i didn`t see any category with WebAPI. So posted under Web services.
I`m working on a WebAPI application (ASP.NET MVC, Entity Framework) & trying to DELETE an entry from Database. Below is the code related to DELETE verb.
- public HttpResponseMessage Delete (int empId)
- {
- try
- {
- using (WebApiTrialEntities entity = new WebApiTrialEntities())
- {
- var isAvailable = entity.Employees.FirstOrDefault(e => e.ID == empId);
- if (isAvailable !=null)
- {
- entity.Employees.Remove(isAvailable);
- entity.SaveChangesAsync();
- return Request.CreateResponse(HttpStatusCode.Gone, "EmpId " + empId + " is Deleted");
- }
- else
- {
- return Request.CreateErrorResponse(HttpStatusCode.NotFound, "EmpId " + empId + " is NotFound");
- }
- }
- }
- catch (Exception ex)
- {
- return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
- }
- }
Using Fiddler - we see Header value as '405 Method Not Allowed' with message as "The requested resource does not support http method 'DELETE'.
Please help me out & suggest me to correct my mistakes.
Thanks in advance.

Midhun TpRank #388 · 6.5K reputationPosted Aug 22, 2017, 8:26 PM EDT
L A180 reputationPosted Aug 29, 2017, 7:07 AM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Aug 3, 2018, 9:46 PM EDT
Ganesh Kadam31 reputationPosted Aug 3, 2018, 3:13 AM EDT
Jenith ThakkarRank #789 · 2.9K reputationPosted Aug 3, 2018, 3:44 AM EDT
Please add this in your web config and try
Ruchi SharavatRank #1,714 · 885 reputationPosted Aug 3, 2018, 4:08 AM EDT
andMadan ShekarRank #428 · 5.9K reputationPosted Oct 17, 2018, 9:34 PM EDT