ServiceStack服务GetRequest不起作用

时间:2014-06-25 21:47:48

标签: servicestack

ServiceStack新手。我设置了一些服务,很多都工作正常。但是我有一个获取请求,由于某种原因没有打我的服务。我可以点击Get返回List但不返回Service返回特定ID。邮差调用只返回OK状态。

这是我的请求类

  [Route("/InspectorIDRequest/{InspectorID}", Verbs = "GET")]
public class GetInspectorIDRequest
{
   public int InspectorID { get; set; }
}

我的服务中的Top方法可以调用 首先通过电话获得点击

  http://localhost:50238/Inspector

第二次Get永远不会被电话打到

 http://localhost:50238/InspectorIDRequest/?InspectorID=2

这是我的服务

    // Returns a list of Inspectors to the user given a GetInspectorsRequest (which is empty)
    public List<Inspector> Get(GetInspectorRequest request)
    {

        InspectorDataWorker pdp = new InspectorDataWorker(Db);
        return pdp.GetInspectorList();
    }

    // Return a single Inspector given their InspectorID
    public Inspector Get(GetInspectorIDRequest request)
    {
        InspectorDataWorker pdp = new InspectorDataWorker(Db);
        return pdp.GetInspectorByID(request.InspectorID);
    }

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

路线http://localhost:50238/Inspector与您的路线定义不符:

[Route("/InspectorIDRequest/{InspectorID}", Verbs = "GET")]

您可以添加一个新的匹配路由,即:

[Route("/InspectorIDRequest")]

或者您可以修改现有路线,使其成为匹配两条路线的通配路线,即:

[Route("/InspectorIDRequest/{InspectorID*}")]

有关路由的更多信息位于Routing wiki