472,374 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

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 4685
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.com
"Andy" <aj********@capcitypress.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.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
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...
3
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...
4
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 =...
4
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...
14
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
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
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...
1
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...
29
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() { //...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.