I get a 404 not found when I try to DELETE from my service, on the client side I use this:
On my Service side I use this:
[OperationContract]
[WebInvoke(Method = "DELETE", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/Student")]
void removeStudent(Student studentID);
List<Student> students = new List<Student>();
public void removeStudent(Student studentID)
{
students.Remove(students.Find(f => f.StudentID.Equals(studentID)));
}
The DELETE Http Verb is not enabled by default. Read this how to fix it.
Based on what i see above, you are passing the some text to the URL on the client side BUT expecting a Student object which doesn't seem right.
I think the convention is that the DELETE should have the same URI template as a GET.
[WebInvoke(Method = "DELETE", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "/{studentID}")]
void removeStudent(string studentID);
or
void removeStudent(int studentID);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.