Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2003, 12:21 PM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I get the true ip address of a client?

Hi there,

I'm not an ASP nor an IIS beginner, so don't tell me to simply use Request.ServerVariables("REMOTE_ADDR"). It works, but it does not work as fine as I need.

Here is my challenge : I am building a web application which needs to be secured (in part) by allowing only some IP addresses to use it. I used Request.ServerVariables("REMOTE_ADDR") for up to three years to retrieve the browsers IP address for many web applications, but one friday morning, I noticed that sometimes the IP address was the IP address of an Internet cache server, not the IP address of the true client.

I'm not a newbie in networking, so don't remind me that when a client is behind a proxy, a firewall, a gateway or a router we can't easily get is IP address and that its true IP address will be unroutable, I already know it and understand it. The clients IP addresses which I wish to verify are public IP addresses and they are routables. The computers which I want to identify are not behind any proxy, firewall, gateway or router, they are simply in a university which use an Internet cache server to visits the web sites for the clients and reduce a little its Internet traffic.

You can easily understand that, if for almost all the computers of an entire university, Request.ServerVariables("REMOTE_ADDR") simply return the IP address of this university's Internet cache server, I can not know if the computer which is trying to access the protected page is one of the allowed one or not. As you can guess, some computers of this university must have the access to the pages and some others should not.

I can not use a software nor an hardware firewall with the server which hosts my web application. This server hosts many other web sites and, most of all, some pages of my web application need to be view from anywhere on the Internet. Only some pages needs restricted access.

I think that it is possible to get the information I want, because I browsed the web with some these computers and some site detected the Internet cache server IP address and some others detected the true IP address. For exemple http://www.lawrencegoetz.com/programs/ipinfo/ tell me the true IP address of my computer but my web site tell me the Internet cache server IP address.

I think that it is possible that the solution may be in the server's configuration or in the Response.CacheControl property or in an other other property like this one. Any clue will be appreciate.

Thanks
 
Old November 5th, 2003, 12:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I visit your site, but it does not display my ip address.
I think it is networking question.
Network specialist can give right answer (reason)
 
Old November 5th, 2003, 10:22 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I hit your page, and I got the IP of my office's gateway router. Looked ok to me.

Like you said, this problem obviously has to do with caching. I haven't used the CacheControl property of Response much, the way I usually resolve this sort of thing is by for page expiration.

Perhaps this will work:
Response.Expires = Now - 1

I built a site once with all pages set like this and even when I hit the [Back] button the page was re-requested from the server so I know that this worked. But I never tested it with a scenario such as yours.

Peter
----------------------------------------
Work smarter, not harder.
 
Old November 5th, 2003, 10:48 AM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Default

hi there,
just wanna point out that the following doesn't work due to different time zones around the globe:
Code:
Response.Expires = Now() - 1
Instead, use the following to work around the time zone differences, so that the page will always expire no matter where you load it from on this planet:
Code:
Response.Expires = -1000000
Sincerely,
Pierre du Toit.
 
Old November 5th, 2003, 10:56 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Good point. I thought that Now - 1 brought Now back 1 day, but I suppose in some places that still wouldn't be enough.

Alternatively you could give it an explicit expiration:
Response.ExpiresAbsolute = #1/1/2000"

Peter
----------------------------------------
Work smarter, not harder.
 
Old January 2nd, 2004, 10:28 PM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys!

I'm unable to continue my work on this application, I lost, a child and my wife, so I'm out of work for a while.:( I will not be able to test your solutions but Response.ExpiresAbsolute = #1/1/2000 sounds great.

YES planoie, Work smarter, not harder... that's a great quote! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
IP Address sumanghosh Classic ASP Basics 1 April 7th, 2006 11:24 AM
How to get IP address shankhan Classic ASP Databases 6 March 10th, 2005 04:18 PM
capture the ip address of the client ranakdinesh BOOK: Professional C#, 2nd and 3rd Editions 1 June 1st, 2004 09:31 AM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.