473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Request.UserHostAddress, Vista & IIS7

Hi,

Now that the VS.NET 2005 SP1 update patch is with us, I'm in the process of
moving my main development environment onto 64-bit Vista Business Edition -
so far, so good...

However, there is a bit of a gotcha with Request.UserHostAddress...

Under IIS6 and earlier, that would return a standard xxx.xxx.xxx.xxx IP
address. However, Vista enables IP6 by default, which makes
Request.UserHostAddress return an IP6 address e.g.
"fe80::2032:39ab:3f57:fffb%10"

Easy enough to disable IP6, of course, but does anyone know a way to return
an IP4 address from IIS7 without disabling IP6, or mucking about with
LMHOSTS...

Haven't been able to find a way so far...
http://west-wind.com/WebLog/posts/8839.aspx
http://forums.asp.net/thread/1667538.aspx

Any assistance gratefully received.

Mark

Apr 26 '07 #1
9 7918
This article shows you how to set Vista to prefer IPv4 to IPv6 when attempting connections:

http://www.microsoft.com/technet/com...uy/cg1005.mspx

To selectively disable Pv6 components and configure behaviors for IPv6 in Windows Vista,
create and configure the following registry value (DWORD type):

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\tcpip6\Parameters\DisabledComponents

DisabledComponents is set to 0 by default.

The DisabledComponents registry value is a bit mask that controls the following series of flags,
starting with the low order bit (Bit 0):

Bit 0 Set to 1 to disable all IPv6 tunnel interfaces, including ISATAP, 6to4, and Teredo tunnels.
Default value is 0.

Bit 1 Set to 1 to disable all 6to4-based interfaces. Default value is 0.

Bit 2 Set to 1 to disable all ISATAP-based interfaces. Default value is 0.

Bit 3 Set to 1 to disable all Teredo-based interfaces. Default value is 0.

Bit 4 Set to 1 to disable IPv6 over all non-tunnel interfaces, including LAN interfaces and
Point-to-Point Protocol (PPP)-based interfaces. Default value is 0.

Bit 5 Set to 1 to modify the default prefix policy table to prefer IPv4 to IPv6 when
attempting connections. Default value is 0.

So, you'd set the first 4 bits to 0 and bit 5 to 1.

That will allow IPv6, but the system will prefer IPv4.

To only prefer IPv4 over IPv6 (what you want), set the value to 0x20
To disable IPv6 over all interfaces *and* prefer IPv4 to IPv6, set it to 0xFF

You must restart the computer for the changes to the DisabledComponents registry value to take
effect.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:uj**************@TK2MSFTNGP05.phx.gbl...
Hi,

Now that the VS.NET 2005 SP1 update patch is with us, I'm in the process of moving my main
development environment onto 64-bit Vista Business Edition - so far, so good...

However, there is a bit of a gotcha with Request.UserHostAddress...

Under IIS6 and earlier, that would return a standard xxx.xxx.xxx.xxx IP address. However, Vista
enables IP6 by default, which makes Request.UserHostAddress return an IP6 address e.g.
"fe80::2032:39ab:3f57:fffb%10"

Easy enough to disable IP6, of course, but does anyone know a way to return an IP4 address from
IIS7 without disabling IP6, or mucking about with LMHOSTS...

Haven't been able to find a way so far...
http://west-wind.com/WebLog/posts/8839.aspx
http://forums.asp.net/thread/1667538.aspx

Any assistance gratefully received.

Mark

Apr 26 '07 #2
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:u4**************@TK2MSFTNGP05.phx.gbl...
This article shows you how to set Vista to prefer IPv4 to IPv6 when
attempting connections:
Superb! Muchas gracias, hombron...

Apr 26 '07 #3
re:
Muchas gracias, hombron...
<chuckle>

You're quite welcome, Mark.
It just so happened that I'd just looked up the very same issue for a client.

:-)


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:O2****************@TK2MSFTNGP04.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:u4**************@TK2MSFTNGP05.phx.gbl...
>This article shows you how to set Vista to prefer IPv4 to IPv6 when attempting connections:

Superb! Muchas gracias, hombron...

Apr 27 '07 #4
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:ez**************@TK2MSFTNGP05.phx.gbl...
It just so happened that I'd just looked up the very same issue for a
client.
Aw - now you've gone and shattered my illusion...

Apr 27 '07 #5
The timing was perfect... :-)


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:eC**************@TK2MSFTNGP04.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:ez**************@TK2MSFTNGP05.phx.gbl...
>It just so happened that I'd just looked up the very same issue for a client.
Aw - now you've gone and shattered my illusion...

Apr 27 '07 #6
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:u4**************@TK2MSFTNGP05.phx.gbl...
This article shows you how to set Vista to prefer IPv4 to IPv6 when
attempting connections:

http://www.microsoft.com/technet/com...uy/cg1005.mspx
I think I've found a way to return the IP4 address even when IP6 is on...

Dns.GetHostAddresses(Dns.GetHostName()) returns an array if IP addresses for
the current host and, so far, the IP4 address always seems to be the fourth
element of the array i.e.

[0]: {fe80::288f:1d8f:3f57:fffb%10}
[1]: {fe80::7133:8615:3971:49d1%8}
[2]: {fe80::5efe:192.168.0.4%13}
[3]: {192.168.0.4}
[4]: {2001:0:4136:e38e:288f:1d8f:3f57:fffb}

Therefore:

using System.Net;
string strIP4Address =
Dns.GetHostAddresses(Dns.GetHostName())[3].ToString();

I need to do a bit more testing to see what that returns on XP / Win2k3s.

Also, it's almost certainly an extremely bad idea to rely on the numerical
position of the element within the array...

--
http://www.markrae.net

Apr 29 '07 #7
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:uY**************@TK2MSFTNGP05.phx.gbl...
I need to do a bit more testing to see what that returns on XP / Win2k3s.
And here we go:

using System.Net;

public string GetIP4Address()
{
string strIP4Address = String.Empty;

foreach (IPAddress objIP in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (objIP.AddressFamily.ToString() == "InterNetwork")
{
strIP4Address = objIP.ToString();
break;
}
}
return strIP4Address;
}

See here for further details:
http://msdn2.microsoft.com/en-us/lib...essfamily.aspx

Apr 29 '07 #8
Good job, Mark!

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:uY**************@TK2MSFTNGP05.phx.gbl...
>I need to do a bit more testing to see what that returns on XP / Win2k3s.

And here we go:

using System.Net;

public string GetIP4Address()
{
string strIP4Address = String.Empty;

foreach (IPAddress objIP in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (objIP.AddressFamily.ToString() == "InterNetwork")
{
strIP4Address = objIP.ToString();
break;
}
}
return strIP4Address;
}
See here for further details:
http://msdn2.microsoft.com/en-us/lib...essfamily.aspx

Apr 29 '07 #9
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eI**************@TK2MSFTNGP05.phx.gbl...
Good job, Mark!
Thanks.

Apr 29 '07 #10

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

Similar topics

2
by: nospam | last post by:
Hi, dont know if this is the correct group, but tried on vista.general and got no help. ive installed VS2005 on RC2 version of Vista and when i try to create a new website project it shows an...
8
by: Darwiniv | last post by:
1. Does anyone run ASAPI and mysql succesfully on Vista /IIS7? 2. Does anyone run CGI and display all SESSION errors on Vista /IIS7? php ASAPI doesn't works with MYSQL. And CGI doesn't show...
1
by: Joey | last post by:
asp.net 2/C#/VS2005 Does anyone know why "Request.UserIPAddress" returns an empty IPV6 address when I run (both serve and browse) my asp.net app on Windows Vista? It all works fine on Windows XP...
10
by: hugh welford | last post by:
Hi Have just installed IIS7 on Vista and am trying to access a .mdb file through ASP. Getting server error. I think the problem is in the file permission. Under XP Pro/IIS6 is used to have to...
5
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi, I wonder if someone could shed some light on this one for me. I have developed a web app in VS2005 with the built in server. It uses an sql database, everytihng works. I need to test it...
0
by: Erwin Moller | last post by:
Hi, I am one of those questionable people that started with Vista (Home Premium). Not because I think it is a ready/steady OS, but partly out of curiousity, and partly because I needed to work...
4
by: PW | last post by:
Has anyone used the traditional Classic ASP / Access DB / IIS configuration on Vista yet? I haven't, but before I upgrade to Vista I would like to ensure all my websites will work once I do. ...
6
by: ma | last post by:
Hello, I am new to IIS and ASP.NET. I wrote my first ASP.NET and I want to deploy in to a system which has Vista Business and IIS7. I copied my files to the target computer and created a virtual...
11
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hello, I have just installed VISTA Enterprise and VS.NET 2008. When pressing F5 to debug my test ASP.NET website, IE 7 display the message "Internet Explorer cannot display the webpage". The...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.