Discover ip address of client

Hi, in a web app,
how can i discover the ip address of a client to log the access to control access of data served by the webapp?

Look at Session.RemoteAddress.

Ok, it work!
Thank you Greg!

Session.RemoteAddress does not work, get a NilObjectException, in a WebServer type app where there is no code in the Session.

Is it possible to get ip in this type of web app? If so how?

Where are you calling Session.RemoteAddress?

In a method in App, The Session has no code, just a window which is not used.

The app does not know what session you are referring to. Hence NilObjectException.
Try calling Self.RemoteAddress in Session and see if it works there.

That does not work. Tried to set a string in Session open with the ip. That works in debugging, but does not in normal running.

Hm…it should. I have multiple apps that use this and haven’t had any issues.

You may ask to early.
In app class you have no session.
But when first webpage opens you have one.

Link does not work?

It working!

Put “Request.RemoteAddress” in the HandleSpecialURL. Event.

[quote=222803:@Jim Smith]It working!

Put “Request.RemoteAddress” in the HandleSpecialURL. Event.[/quote]

Jim, forgive me, but this does not sound right. When the user connects normally, HandleSpecialURL does not fire.

HandleURL does fire, but you have to use WebSessionContext to reconcile the data with the session.

Won’t you simply try to get Session.RemoteAddress in the default WebPage Shown event instead of Session.Open ?

[quote=222806:@Michel Bujardet]Jim, forgive me, but this does not sound right. When the user connects normally, HandleSpecialURL does not fire.

HandleURL does fire, but you have to use WebSessionContext to reconcile the data with the session.[/quote]

This is not a web app where user is in a web browser; this if for a web server type app where a desktop app is calling (POST) so “HandleSpecilURL” does fire.

You should have told. Of course that is exactly how it works to get the IP there. Since there is no session, what you were trying to do first would have never worked.

Ah…makes sense now. :slight_smile: