472,371 Members | 1,531 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,371 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 7826
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...
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: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
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...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
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.