【问题标题】:ISAPI webbroker requestcontentfields is empty (length = 0)ISAPI webbroker requestcontentfields 为空(长度 = 0)
【发布时间】:2016-09-19 06:47:11
【问题描述】:

我使用向导创建了一个网上经纪服务应用程序。我更改了默认操作的代码,如下所示:

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  i: Integer;
begin
  i := Request.ContentLength;
  Response.Content :=
    '<html>' +
    '<head><title>DataSnap Server</title></head>' +
    '<body>DataSnap Server x' +
    Request.ContentFields.Text + 'x' + IntToStr(i) + 'x' +
    '</body>' +
    '</html>';
end;

我在 IIS (6.2 - Server 2012) 下部署了 dll,并使用网络浏览器测试了 dll。

http://localhost/MapServer/Mapserver.dll/?param1=hello

我试过了

http://localhost/MapServer/Mapserver.dll/?param1="你好"

浏览器输出

DataSnap 服务器 xx0x

在这两种情况下。

看来Request.ContentFields 没有被来自浏览器的调用填充。

此问题是否特定于特定版本的 Delphi 和/或 IIS?我不明白什么?

西雅图和柏林我都试过了,结果是一样的。 谢谢

附:我还使用该向导制作了一个独立的网上经纪商。没有这个问题。

【问题讨论】:

    标签: delphi iis datasnap webbroker


    【解决方案1】:

    经过一些非常深入的 Google 搜索后,我找到了答案:(请注意,虽然 Embarcadero 文档声明 Request.ContentFields 包含字段“当 MethodType 为 mtPost”时的内容,但实际上无用的 Request.QueryFields 文档什么也没说关于mtGet)

    procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
    var
      i: Integer;
    begin
      i := Length(Request.QueryFields.Text);
      Response.Content :=
        '<html>' +
        '<head><title>DataSnap Server</title></head>' +
        '<body>DataSnap Server x' +
        Request.QueryFields.Text + 'x' + IntToStr(i) + 'x' +
        '</body>' +
        '</html>';
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-21
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      • 2017-11-10
      • 1970-01-01
      相关资源
      最近更新 更多