Results 1 to 5 of 5

Thread: how to write an httphander?

  1. #1

    how to write an httphander?

    On trying to write a httphandler with the delphi prism command line it get the following error:

    C:\Projecten\Oxygene\MyHandler.pas(8,35) : Error : (PE66) Interface property g
    etter not implemented for "System.Web.IHttpHandler.IsReusable"


    This is the source:
    [pascal]
    unit MyHandler;

    interface

    uses System.Web;

    type
    HelloWorldHandler = public class(System.Object,IHttpHandler)
    public
    public function GetIsReuseable: boolean;
    procedure ProcessRequest(context: HttpContext);
    property IsReuseable: boolean read GetIsReuseable;
    end;

    implementation

    function GetIsReuseable: boolean;
    begin
    Result := false;
    end;

    procedure HelloWorldHandler.ProcessRequest(context: HttpContext);
    begin
    context.response.Write('Hello World');
    end;

    end.
    [/pascal]

    And this is how i compile:
    Code:
    Oxygene MyHandler.pas /assemblyname:MyHandler /type:library /frameworkfolder:C:\WINDOWS\Microsoft.NET\FrameWork\v2.0.50727 /ref:$(Framework)\System.Web.dll /ref:$(Framework)\System.dll
    I also tried using get_IsReuseable instead of GetIsReuseable but that only leads to more errors ...

    Thanks in advance for your help.
    http://3das.noeska.com - create adventure games without programming

  2. #2
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: how to write an httphander?

    I'm not a .Net user, but standard Object Pascal syntax dictates you need 'HelloWorldHandler.' in front of methods belonging to the class. Your getIsReusable handler doesn't have that.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  3. #3

    Re: how to write an httphander?

    You are right it should be there, but it does not solve the problem the same error message is stil there Also removing the double public declaration does not help either.
    http://3das.noeska.com - create adventure games without programming

  4. #4
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: how to write an httphander?

    If that doesn't work, I'm sorry hon, I can help no more as I don't have access to Delphi Prism or any other .Net compiler.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #5

    Re: how to write an httphander?

    Dont feel bad about it. I should blame me for writing an half implementation.
    With the classname in front of the funtion get_IsReuseable started to work also i added an constructor so the code now looks like this:

    [pascal]
    unit MyHandler;

    interface

    uses System.Web;

    type
    HelloWorldHandler = class(IHttpHandler)
    public
    constructor Create;
    function get_IsReusable: Boolean;
    property IsReusable: Boolean read get_IsReusable;
    procedure ProcessRequest(context: HttpContext);
    end;

    implementation

    constructor HelloWorldHandler.Create;
    begin
    inherited Create;
    end;

    function HelloWorldHandler.get_IsReusable: Boolean;
    begin
    Result := False;
    end;

    procedure HelloWorldHandler.ProcessRequest(context: HttpContext);
    var
    Response: HttpResponse;
    Request: HttpRequest;
    begin
    Request := context.Request;
    Response := context.Response;
    Response.Write('<html>');
    Response.Write('<body>');
    Response.Write('<h1>Hello from a synchronous custom HTTP handler written in
    Delphi Prism.</h1>');
    Response.Write('</body>');
    Response.Write('</html>');
    end;

    end.
    [/pascal]

    And compiles with this:
    Code:
    Oxygene MyHandler.pas /assemblyname:MyHandler /type:library /frameworkfolder:C:\WINDOWS\Microsoft.NET\FrameWork\v2.0.50727 /ref:$(Framework)\System.Web.dll /ref:$(Framework)\System.dll
    And in web.config the following should be added to the httphandlers:

    <add verb="*" path="*.sample" type="MyHandler.HelloWorldHandler,MyHandler"/>


    So http://localhost/test/test.sample shows Hello from a synchronous custom HTTP handler written in Delphi Prism.

    _________________________________________________

    I use the free command line edition of Delphi Prism which can be downloaded for free at: http://cc.codegear.com/Free.aspx?id=26256
    http://3das.noeska.com - create adventure games without programming

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •