mvanrijnen 123 Posted August 9, 2023 (edited) My base class (partial): In the following example, the RemoteIP is not filled when using ISAPI dll, running onder IIS TMyMars=class private FRequestID: string; FResourcePath: string; FRequestTimeStamp: TDateTime; FRequestIPSource: string; FMethodName: string; protected [Context] marsRequest: IMARSRequest; [Context] Response: IMARSResponse; [Context] Activation : IMARSActivation; procedure DumpJSON(const AFileNamePrefix, AJSON, AFolder : string; const APathSplit : TPathSplit); public constructor Create; virtual; [BeforeInvoke] procedure BeforeInvoke; virtual; [AfterInvoke] procedure AfterInvoke; virtual; [InvokeError] function ErrorHandler(const AException: Exception): Boolean; virtual; [Get, Path('ping'), Produces(TMediaType.APPLICATION_JSON)] function Ping(): TPingResult; property ResourceMethodName: string read FMethodName; property ResourcePath : string read FResourcePath; property RequestTimeStamp: TDateTime read FRequestTimeStamp; property RequestID: string read FRequestID; property RequestIPSource: string read FRequestIPSource; end; implementation: procedure TMyMars.BeforeInvoke; begin LogExDebug('RemoteIP: %s', [marsRequest.RemoteIP], 'TMyMars.BeforeInvoke'); FResourcePath := Activation.ResourcePath; FRequestIPSource := marsRequest.RemoteIP; FMethodName := Activation.Method.Name; end; Edited August 9, 2023 by mvanrijnen Share this post Link to post
mjustin 23 Posted August 10, 2023 (edited) Does marsRequest.RemoteIP contain an empty string, or an unexpected value? And do the other fields of marsRequest contain sensible (non-default) values? Edited August 10, 2023 by mjustin Share this post Link to post
mvanrijnen 123 Posted August 15, 2023 hmz, made a dump of the other values in the request: Accept: */* Authorization: Method: POST QueryString: RawPath: /rest/default/MyWebhookReceiver/ Hostname: my.wscompany.eu RemoteIP: UserAgent: PostmanRuntime/7.32.1 @Andrea Magni Seems not everything is filled? Do i have to configure something for this to work ? in MARS or in IIS ? Share this post Link to post
mvanrijnen 123 Posted August 15, 2023 (edited) Attached the debugger, here is where i come out: Unit: Web.HTTPapp function TWebRequest.GetRemoteIP: string; begin Result := EmptyStr; end; explains a lot 🙂 how to fix? [edit] got a fix (needs to be double checked) Replace RemoteIP in the FWebrequest to RemoteAddr. Unit: MARS.http.Server.Indy: Code: function TMARSWebRequest.GetRemoteIP: string; begin // Result := FWebRequest.RemoteIP; Result := FWebRequest.RemoteAddr; end; Edited August 15, 2023 by mvanrijnen Share this post Link to post