404 not found when I try to DELETE from my service

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)));
    }

Answers


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 DELETE Http Verb is not enabled by default. Read this how to fix it.


Need Your Help

std::wstring pointer assignment C++

c++ pointers wstring

I am trying to assign a value to a wstring pointer and the value does not get assigned; however, when I break the creation and assignment of the pointer into two lines, it works. Why is this?