3

我将 ServiceStack 与 Razor 插件一起使用,并从我的服务方法返回响应对象。如果服务使用默认视图,则响应很好,但如果我在服务方法中指定视图,则 http 响应包含围绕内容的附加数据。

这是一个测试服务类:

[DefaultView("TestView")]
public class TestService : RestServiceBase<Req>
{
    public override object OnGet(Req request)
    {
        var response = new Req { Data = "Hello" };
        if (string.IsNullOrEmpty(request.Data))
        {
            return response;
        }
        return new HttpResult(response) { View = "TestView" };
    }
}

包含附加内容数据的示例原始响应如下所示:

HTTP/1.1 200 OK
Server: nginx/1.2.3
Date: Thu, 03 Jan 2013 12:46:33 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: ServiceStack/3.928 Unix/Mono
X-AspNet-Version: 4.0.30319
Cache-Control: private
Set-Cookie: ss-id=KvFQKAyOkkKMajEFeaLiKQ==; path=/
Set-Cookie: ss-pid=nrv3gwEL6EuRE9B8VpAWZA==; path=/; expires=Mon, 03 Jan 2033 12:43:57 GMT

b1
a4
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test page</title>
</head>
<body>

<h1>Test page</h1>
<p>Hello</p>

</body>
</html>

0


0

它们看起来像内容长度值和结束标记。我想我有一些错误配置,但不知道是什么。有任何想法吗?

4

0 回答 0