Skip to content

Instantly share code, notes, and snippets.

@scottmcarthur
Created May 29, 2014 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottmcarthur/c07f77cfcaa3ba5edd61 to your computer and use it in GitHub Desktop.
Save scottmcarthur/c07f77cfcaa3ba5edd61 to your computer and use it in GitHub Desktop.
ServiceStack HttpError.NotFound bug when using DELETE method
using System;
using Funq;
using ServiceStack;
namespace V4
{
class MainClass
{
public static void Main()
{
// Simple Self-Hosted Console App
var appHost = new AppHost(500);
appHost.Init();
appHost.Start("http://*:9000/");
Console.ReadKey();
}
}
public class AppHost : AppHostHttpListenerPoolBase
{
public AppHost(int poolSize) : base("Test Service", poolSize, typeof(TestService).Assembly)
{
}
public override void Configure(Container container)
{
SetConfig(new HostConfig {
DebugMode = true
});
}
}
[Route("/Test1", "DELETE")]
public class Test1Request {}
[Route("/Test2", "DELETE")]
public class Test2Request {}
[Route("/Test3", "DELETE")]
public class Test3Request {}
public class TestService : Service
{
public string Delete(Test1Request request)
{
// Works as expected
return "hello";
}
public string Delete(Test2Request request)
{
// Shows a handler not found error instead of custom 404??
throw HttpError.NotFound("No such record");
return "hello";
}
public string Delete(Test3Request request)
{
// Works as expected
throw HttpError.Unauthorized("Unauthorized");
return "hello";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment