I'm using OpenRasta framework in a .net service and I've a method as below in the handler
public OperationResult Delete(int Id)
{
// Do some operation and get an entity
return new OperationResult.OK(MyResource);
}
My configuration looks like below:
ResourceSpace.Has.ResourcesOfType<MyResource>()
.AtUri("/MyResource/{Id}")
.And.AtUri("/MyResource")
.HandledBy<MyResourceHandler>()
.AsJsonDataContract().ForMediaType("application/json")
.And.AsXmlDataContract().ForMediaType("application/xml");
My request is framed as below
HttpMethod: DELETE
AcceptHeader: "application/xml"
URI: http://localhost/MyResource/a
Please observe the resource parameter: delete method accepts integer whereas I'm passing a character.
With this request I expected 404 status code instead I got 405 Method not allowed. Can anybody explain this behavior, why it is returning 405?
If I give incorrect resource name in the URI it returns me 404. for ex: URI:http://localhost/OtherResource/a
Update: I'm testing this using OpenRasta's InMemoryHost and Delete method is supported
I believe the behavior to be correct. The URI entered matches one OpenRasta owns, and you have a method in which the Id is an int. The URI gets parsed and no method on the registration can be executed (none of them have a string as the Id), so OR is out of choices and know that while the resource has been registered, there is no method it can execute with the current request, hence the 405.