473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting client ip address

Hi all,

I'm trying to write some code in a business layer which will audit the
IP address that the request is coming from.

If the business layer is being called from a web app, I'd like to get
the IP address of the client browser, but if the business layer is
being called from a desktop app, i'd like to capture the desktop's IP
address.

The catch is that I don't want to have to pass the IP address from the
UI layer into the business layer; the business layer should be able to
detect this automatically.

Any ideas?

Thanks
Andy

Nov 23 '05 #1
4 4771
Dns.Resolve(Dns .GetHostName()) .AddressList
This will return all the IP addresses of the machine. I don't know how to
get it from a browser, it's the wrong group for that.

Cheers,
Mark

"Andy" wrote:
Hi all,

I'm trying to write some code in a business layer which will audit the
IP address that the request is coming from.

If the business layer is being called from a web app, I'd like to get
the IP address of the client browser, but if the business layer is
being called from a desktop app, i'd like to capture the desktop's IP
address.

The catch is that I don't want to have to pass the IP address from the
UI layer into the business layer; the business layer should be able to
detect this automatically.

Any ideas?

Thanks
Andy

Nov 23 '05 #2
I know how to get it from a browser, so i guess the question is
technically how do i detect if i'm running an IIS process or not, and
if i am running under one, how can i get the HttpContext object.

Andy

Nov 23 '05 #3
Andy,

You can do this by checking the static Current property on the
HttpContext class. If there is one, then you will be able to get it here.

However, if you are going to use these objects through remoting, I don't
know that it would be possible to actually get the IP address of the client.
You should have your client objects get the IP address yourself, and then
pass that long with the call.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Andy" <aj********@cap citypress.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
I know how to get it from a browser, so i guess the question is
technically how do i detect if i'm running an IIS process or not, and
if i am running under one, how can i get the HttpContext object.

Andy

Nov 23 '05 #4
if(HttpContext. Current !=null)
.....

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Andy" wrote:
I know how to get it from a browser, so i guess the question is
technically how do i detect if i'm running an IIS process or not, and
if i am running under one, how can i get the HttpContext object.

Andy

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2298
by: Chris | last post by:
<apologies for cross-posting> Hi All, I am based in the UK and have been doing some private work for a client which involved setting up a database and scripts to search it and display results etc, all the usual stuff. The work was at about the halfway point when the client asked for a time estimate for the whole project. I sent him this and he wrote back
3
8985
by: roger beniot | last post by:
I would like to figure out how to detect an IP address change for an XP/Win2K3 machine that is leasing an IP via DHCP (and do it in C#)... Is there any event that indicates an IP address change?... I really don't want to poll for a change. I would like to get an event indicating the IP address has changed and propogate that change to other levels of my app. If anyone has a solution that isn't in C# I am interested in that as
4
4572
by: anonymous_c | last post by:
Hey guys. I'm creating a file transfer app. Anyways, I'm using this code... SERVER <code>Dim Hostname As String = Dns.GetHostName Dim IP As String = Dns.GetHostByName(Hostname).AddressList(0).ToString Public Sub RunServer() Dim listener As TcpListener
4
6097
by: Goh | last post by:
Hi, I would like to know how can we implement a web page that intelligent enough to unique identify that pc have been visit before without any cookies and login user require. I have try implement this by MAC address. When user browser the web site I sometime can get user pc MAC and sometime no. Why this type of implementation are so not consistency? Does any
14
4452
by: Ankit Aneja | last post by:
The code of classes given below is for server to which clients connect i want to get ip address of client which has connected pls help how can i get //listen class public class listen {
6
10751
by: Prabhat | last post by:
Hi Friends, It it possible to get the MAC Address of the client PC using ASP. Also can I get the HDD ID/Serial Number also using asp? Please advice. Thanks Prabhat
4
7313
by: Macca | last post by:
Hi, I am using an asynchronous socket server to allow comms between multiple clients and my server. I know how to obtain the IPAddress of the client (network device) as shown below :- string sensorIPAddress = ((IPEndPoint)handler.RemoteEndPoint).Address.ToString(); but what I would like to obtain is the physical/MACID of the client.
1
3200
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as follows: The code below is for the first page:session_start is in line 3 <link href="css/jobSheet.css" rel="stylesheet" type="text/css" /> session_start();
29
37509
pradeepjain
by: pradeepjain | last post by:
Hii, I need to know is there any way to get the mac id's of the machines accessing ma site! I want to make a access lock using the mac id's <?php function returnmacaddress() { // This code is under the GNU Public Licence // Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com // Tested only on linux, please report bugs // WARNING: the commands 'which' and 'arp' should be executable
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.