Re: Create a free service
This prints out the IP address of the visitor.
Code:
<%=Request.ServerVariables("REMOTE_ADDR")%>
For more server variables visit this link.
Re: Create a free service
If you want an ASP .NET based solution you may use the following code.
PHP Code:
string ip;
ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR");
if(ip==string.Empty)
{
ip=Request.ServerVariables("REMOTE_ADDR");
}
Re: Create a free service
If your real need is the ability to "discover" the public IP address of a NAT router from inside your programs there are alternatives. One is to ask the router itself.
[VB6] PortMapper - UPnP NAT Traversal Class can do this if you make a few assumptions: the router must be somewhat recent and support UPnP, the router must have UPnP enabled, the OS must be WinXP or later, the OS must have Network Discovery installed and enabled (typically it is), and the Windows firewall (or other software firewall) must allow UPnP traffic through it.
That may sound like a lot of "ifs" but it really isn't too bad. And once you have that your program can automatically map ports through to your server program as well.
Use the latest version there. The only part I hadn't added was the ability to set the Windows Firewall to allow TCP or UDP ports "through" but this can also be automated with a little more work and a DLL from the DirectX SDK (or a little more work using standard API calls).
Re: Create a free service
Thanks for the reply... :wave:
Actually, I want the country name of the user.... And display some message like, "you are from India". I think, IP address can be used to track this down....
Re: Create a free service
Quote:
Originally Posted by
akhileshbc
Thanks for the reply... :wave:
Actually, I want the country name of the user.... And display some message like, "you are from India". I think, IP address can be used to track this down....
You might want to read this article.
Re: Create a free service
Thanks abhi.... :wave:
Ok... Now I know to track the the Country from IP Address...
What should I have to do, if I want this feature to be publically available...??? I mean, users can use this service in their website or in forums, by copying and pasting a code from my website...
Re: Create a free service
Yes. You'll need to create a web service.
Are you working with ASP or ASP .NET?
Re: Create a free service
Re: Create a free service
You're going to have to write out graphic objects yourself. This sucks in Classic ASP.
Also, this isn't a web service; this is simply letting browsers download an image from your server; you're just dynamically generating the image.
In ASP.Net you'd create a generic handler for this but a content page would also work (just has extra overhead). In Classic ASP you'd just create a new page.
Make sure to return the appropriate headers for the image format you're writing out and you'll need to write this data to the response buffer so that it's sent to the user as a file.
Captchas work this way as well so if you search for a tutorial you could look for those as well.
Re: Create a free service
Thanks Kasracer :wave:
Is it possible to track the ip address of the user using this method....???? (I will be displaying the Country Name in a picture(like you said) on the webpage.... People can copy - paste the link from my site, so that this image or service can be used in their forum signature or websites, etc...)
Re: Create a free service
Yes. Every request made to a web server includes the client's IP address. Naturally, this can be spoofed, but you should be able to grab this information out of the HTTP headers as shown above. You'll just need to figure out how to map an IP address to a country.
Re: Create a free service
Quote:
You'll just need to figure out how to map an IP address to a country.
Yeah... I had gone through some Googling and find some codes...
Database found here