How can I implement CustomResponseEvent in .NET?

Hi,

I have the following code in a Delphi RO server:

procedure TServerDataModule.ServerCustomResponseEvent(const aTransport: IROHTTPTransport;
  const aRequestStream, aResponseStream: TStream; const aResponse: IROHTTPResponse; var aHandled: Boolean);

  procedure WriteAnsiString(aStr: AnsiString);
  begin
    aResponseStream.Write(pointer(aStr)^, Length(aStr));
  end;

var
begin
  aHandled := MatchText(aTransport.PathInfo, ['/healthcheck_elb', '/healthcheck']);
  if aHandled then
  begin
    // Code to check server status...
	
    aResponse.Code := HTTP_OK;
    WriteAnsiString('Health Check OK');
  end;
end;

How can I implement something like this a .NET server? Do I need to implement my own IHttpDispatcher?

Thanks,
Arturo.

That would be the easiest solution and that’s what IHttpDispatcher is designed for.
Otherwise you’d hook up the server Http request event and handle it - that will require significantly more code to implement properly.

Ok, I’ll look into this and implement a custom IHttpDispatcher for this requirement.

Thanks!

-Arturo.

In case of any difficulties don’t hesitate to ask for help and we’ll provide you a sample IHttpDispatcher implementation.