Atozed Forums
WebApplication.IP change from IW15.x to IW16.2 - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: WebApplication.IP change from IW15.x to IW16.2 (/thread-6456.html)



WebApplication.IP change from IW15.x to IW16.2 - alex.trejo@tttnet.com.mx - 09-09-2026

I have a dll which in Audit records user activity and IP, using WebApplication.IP. This under delphi 10.2.3 and IW15.x

A new application using same audit (Delphi 12.2 IW16.2), reports under WebApplication.IP our internal server rather than user IP.

Should I use a diferent routine?


RE: WebApplication.IP change from IW15.x to IW16.2 - MJS@mjs.us - 09-11-2026

(09-09-2026, 03:02 AM)alex.trejo@tttnet.com.mx Wrote: I have a dll which in Audit records user activity and IP, using WebApplication.IP. This under delphi 10.2.3 and IW15.x

A new application using same audit (Delphi 12.2 IW16.2), reports under WebApplication.IP our internal server rather than user IP.

Should I use a diferent routine?

This is what I use to get the actual IP:

String rip = WebApplication->Request->GetRawHeaderValue("X-Real-IP");
if(rip == "") rip = WebApplication->IP;


RE: WebApplication.IP change from IW15.x to IW16.2 - alex.trejo@tttnet.com.mx - 09-21-2026

Since we have an internal proxy, we obtained it this way:

function TIWUserSession.DameHeaderHTTP(const ANombre: string): string;
var
  i, p: Integer;
  Linea: string;
begin
  Result:='';
  for i:=0 to WebApplication.Request.RawHeaders.Count-1 do
  begin
    Linea:=WebApplication.Request.RawHeaders[i];
    p:=Pos(':',Linea);
    if (p>0) and SameText(Trim(Copy(Linea,1,p-1)),ANombre) then
    begin
      Result:=Trim(Copy(Linea,p+1,MaxInt));
      Exit;
    end;
  end;
end;

function TIWUserSession.DameIPCliente: string;
var
  IPRemota, XFF: string;
  p: Integer;
begin
  IPRemota:=WebApplication.Request.RemoteAddr;
  Result:=IPRemota;

  if IPRemota='XXX.XXX.XXX.XXX' then  //internal proxy IP
  begin
    XFF:=DameHeaderHTTP('X-Forwarded-For');

    // Si hubiera varios valores, toma el último agregado por el proxy.
    p:=LastDelimiter(',',XFF);
    if p>0 then
      XFF:=Trim(Copy(XFF,p+1,MaxInt))
    else
      XFF:=Trim(XFF);

    if XFF<>'' then
      Result:=XFF;
  end;
end;