c# - HTTP Error 405 Method not allowed while calling web api delete method? -


i trying call mvc controller application webapi applicaiton method. getting error 405 method not allowed. working fine while calling , post.

mvc applicaiton:

[httppost] public httpresponsemessage deleteservice(int id) {         //code webapi     } 

web api application:

[httpdelete] public httpresponsemessage deleteservice(int id) {         try {             servicesmodel service = dbcontext.services.find(id);             ienumerable<servicepropertiesmodel> serviceproperies = dbcontext.serviceproperties.where(x => x.serviceid == id);             if (service != null) {                  foreach (servicepropertiesmodel s in serviceproperies) {                     dbcontext.serviceproperties.remove(s);                 }                 dbcontext.services.remove(service);                 dbcontext.savechanges();             }             return request.createresponse(httpstatuscode.ok);         } catch {             return request.createresponse(httpstatuscode.badrequest);         }     } 

thnaking you. regards,sekhar

the methods put , delete not allowed default. have allow them in web applications web.config.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -