Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > beginner question: local IP-Address

Reply
Thread Tools

beginner question: local IP-Address

 
 
=?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=
Guest
Posts: n/a
 
      04-11-2005
I looked in the help but I cannot find the method to retrieve the IP-Address
of the local machine in the code behind (not the client machine, wich I can
retrieve with Request.UserHostAddress, but the IP-Address of the server where
the code behind is running).
I checked IPAddress Class but this seems not to be the correct one.
Thank you for your help
 
Reply With Quote
 
 
 
 
Joseph Byrns
Guest
Posts: n/a
 
      04-11-2005
You can do:

System.Net.Dns.GetHostByName(System.Net.Dns.GetHos tName()).AddressList(0).ToString


"Carlo Marchesoni" <> wrote in
message news:B7B38011-0358-4A6C-AA26-...
>I looked in the help but I cannot find the method to retrieve the
>IP-Address
> of the local machine in the code behind (not the client machine, wich I
> can
> retrieve with Request.UserHostAddress, but the IP-Address of the server
> where
> the code behind is running).
> I checked IPAddress Class but this seems not to be the correct one.
> Thank you for your help



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      04-11-2005
Request.ServerVariables("LOCAL_ADDR")

would provide the server's IP address, too.




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <> wrote in message
news:...
> You can do:
>
> System.Net.Dns.GetHostByName(System.Net.Dns.GetHos tName()).AddressList(0).ToString
>
>
> "Carlo Marchesoni" <> wrote in
> message news:B7B38011-0358-4A6C-AA26-...
>>I looked in the help but I cannot find the method to retrieve the
>>IP-Address
>> of the local machine in the code behind (not the client machine, wich I
>> can
>> retrieve with Request.UserHostAddress, but the IP-Address of the server
>> where
>> the code behind is running).
>> I checked IPAddress Class but this seems not to be the correct one.
>> Thank you for your help

>
>




 
Reply With Quote
 
=?Utf-8?B?U2NjcjE4?=
Guest
Posts: n/a
 
      06-22-2005
I'm not sure if this exactly what you want to do, but you can display the
account that an ASP.net page is exeuting by in Sub Page_Load
lblAccount.text = System.Security.Principal.WindowsIdentity.GetCurre nt().Name
Hope this helps.

Sccr18

"Juan T. Llibre" wrote:

> Request.ServerVariables("LOCAL_ADDR")
>
> would provide the server's IP address, too.
>
>
>
>
> Juan T. Llibre
> ASP.NET MVP
> http://asp.net.do/foros/
> Foros de ASP.NET en Español
> Ven, y hablemos de ASP.NET...
> ======================
>
> "Joseph Byrns" <> wrote in message
> news:...
> > You can do:
> >
> > System.Net.Dns.GetHostByName(System.Net.Dns.GetHos tName()).AddressList(0).ToString
> >
> >
> > "Carlo Marchesoni" <> wrote in
> > message news:B7B38011-0358-4A6C-AA26-...
> >>I looked in the help but I cannot find the method to retrieve the
> >>IP-Address
> >> of the local machine in the code behind (not the client machine, wich I
> >> can
> >> retrieve with Request.UserHostAddress, but the IP-Address of the server
> >> where
> >> the code behind is running).
> >> I checked IPAddress Class but this seems not to be the correct one.
> >> Thank you for your help

> >
> >

>
>
>
>

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-22-2005
That's not what he was looking for.

He was looking for "the IP Address of the
server where the code behind is running".

re:
> lblAccount.text = System.Security.Principal.WindowsIdentity.GetCurre nt().Name


That should be
System.Security.Principal.WindowsIdentity.GetCurre nt.Name()

I published this short file I wrote, which retrieves the
account name ASP.NET is running under, a few days ago.

Check it out...

-----------------
<%@ Page Language="VB" %>
<%@ Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
-------------




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Sccr18" <> wrote in message
news:4EBA0623-F365-4885-9B2C-...
> I'm not sure if this exactly what you want to do, but you can display the
> account that an ASP.net page is exeuting by in Sub Page_Load
> lblAccount.text = System.Security.Principal.WindowsIdentity.GetCurre nt().Name
> Hope this helps.
>
> Sccr18
>
> "Juan T. Llibre" wrote:
>
>> Request.ServerVariables("LOCAL_ADDR")
>>
>> would provide the server's IP address, too.
>>
>>
>>
>>
>> Juan T. Llibre
>> ASP.NET MVP
>> http://asp.net.do/foros/
>> Foros de ASP.NET en Español
>> Ven, y hablemos de ASP.NET...
>> ======================
>>
>> "Joseph Byrns" <> wrote in message
>> news:...
>> > You can do:
>> >
>> > System.Net.Dns.GetHostByName(System.Net.Dns.GetHos tName()).AddressList(0).ToString
>> >
>> >
>> > "Carlo Marchesoni" <> wrote in
>> > message news:B7B38011-0358-4A6C-AA26-...
>> >>I looked in the help but I cannot find the method to retrieve the
>> >>IP-Address
>> >> of the local machine in the code behind (not the client machine, wich I
>> >> can
>> >> retrieve with Request.UserHostAddress, but the IP-Address of the server
>> >> where
>> >> the code behind is running).
>> >> I checked IPAddress Class but this seems not to be the correct one.
>> >> Thank you for your help
>> >
>> >

>>
>>
>>
>>



 
Reply With Quote
 
sobreiro sobreiro is offline
Junior Member
Join Date: Dec 2006
Posts: 2
 
      07-18-2008
Hi guys,

one more thing to talk about getting the local address.

doing this:
System.Net.Dns.GetHostByName(System.Net.Dns.GetHos tName()).AddressList[0]

you get the correct ip

doing this way:

HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"];

you get the 127.0.0.1, that´s not wrong, but doent help so much

I hope it helps. regards
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Local MAC Address Booter Python 12 04-07-2010 07:32 AM
Local machine's MAC address? SJ ASP .Net 4 03-09-2006 07:34 AM
How to get the local mac address? Daniel Crespo Python 24 12-19-2005 11:30 PM
Re: How to get the local mac address? mwilliams Python 0 12-15-2005 03:02 PM
No Class at ALL!!! beginner/beginner question =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= ASP .Net 7 02-03-2005 01:47 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57