在AppHost中
public override void Configure(Funq.Container container)
{
JsConfig.IncludeNullValues = true;
SetConfig(new EndpointHostConfig
{
ServiceStackHandlerFactoryPath = "api",
DefaultContentType = ServiceStack.Common.Web.ContentType.Json,
DefaultJsonpCacheExpiration = new TimeSpan(0, 0, 0, 0),
GlobalResponseHeaders = { { "Cache-Control", "no-cache" } },
});
...
当我执行Dto.ToJson()时,空字段根本没有被序列化。发现这是因为我的服务引发了序列化错误。