简体   繁体   English

ServiceStack请求参数丢失

[英]ServiceStack request parameters missing

I'm doing a service with ServiceStack, and I'm having a problem. 我正在使用ServiceStack进行服务,但遇到了问题。 I don´t see the request parameters, so, when I call the method, all parameters of the request are null. 我看不到请求参数,因此,当我调用该方法时,请求的所有参数均为空。 Here is the code: 这是代码:

public class AppHost : AppSelfHostBase
{
    public AppHost()
        : base("CallbackServer", typeof(CallbackServer).Assembly)
    {
    }

    public override void Configure(Container container)
    {
    }
}

public class CallbackServer : Service
{
    public HttpResult Post(EventoCliente request)
    {
        request.TimeReceived = DateTime.Now;
        Task.Factory.StartNew(() => Program.EventArrived(request));
        return new HttpResult(HttpStatusCode.OK,"OK");
    }
}

[Route("/turno", "Post")]
public class EventoCliente : IReturn<EventoClienteResponse>
{
    public TurnoCliente Turno;
    public string Sucursal;
    public string[] Puestos;
    public DateTime? TimeReceived;
}

public class EventoClienteResponse
{
    public ResponseStatus ResponseStatus { get; set; }
}

static void Main()
{
    var appHost = new AppHost();
    appHost.Init();
    appHost.Start("http://*:9900/NesrEmulator/");
}

So, in the browser i write: http://localhost:9900/NesrEmulator , and i can see the method EventoCliente, but i can´t see (there aren´t) the parameters for the request. 因此,在浏览器中,我编写了: http:// localhost:9900 / NesrEmulator ,并且可以看到EventoCliente方法,但是看不到(没有)请求的参数。 这是我的意思的屏幕截图...

What i´, doing wrong? 我在做什么,错了吗? Thanks 谢谢

Your DTO's should use public properties not public fields so just change it to: 您的DTO应该使用公共属性而不是公共字段,因此只需将其更改为:

[Route("/turno", "Post")]
public class EventoCliente : IReturn<EventoClienteResponse>
{
    public TurnoCliente Turno { get; set; }
    public string Sucursal { get; set; }
    public string[] Puestos { get; set; }
    public DateTime? TimeReceived { get; set; }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM