Owen Lilly
Owen Lilly

Reputation: 171

ServiceStack X-HTTP-Method-Override

I have a ServiceStack web service that requires support for the X-HTTP-Method-Override header.

I tried simulating the Delete request to through a Get request with the X-HTTP-Method-Override header set but I get a:-

404 - Handler for Request not found

Here's what the request format:

Get - http://localhost/test/1

Headers

User-Agent: Fiddler
Host: localhost
X-HTTP-Method-Override: Delete

And the Service and its DTO implementation looks like:

[Route("/test/{id}", HttpMethods.Delete)]
public class TestRequest {
    public int id { get; set; }
}

public class TestService : Service {

    public object Delete(TestRequest request){
        return request.id;
    }
}

I found a snippet in the ServiceStack source that says X-HTTP-Method-Override feature is supported.

Is there something else I need to configure in the project to get this to work? Help please...

Upvotes: 1

Views: 712

Answers (1)

Owen Lilly
Owen Lilly

Reputation: 171

I figured it out, I have the add the Get verb to the request dto like this:

[Route("/test/{id}", "Delete,Get")]
public class TestRequest {
    public int id { get; set; }
}

Now the Delete method will be called when simulated via the Get request via the X-HTTP-Method-Override

public class TestService : Service {

    public object Delete(TestRequest request){
        return request.id;
    }
}

Upvotes: 1

Related Questions