Wie kann ich in VirtualBox vom Host aus auf den Host localhost zugreifen (Visual Studio Dev Server von der IE7-Test-VM)?

8539
Seth

Das Host-Betriebssystem ist Win7, auf dem MyApp im Visual Studio Development Server ausgeführt wird, das an localhost gebunden ist: 51227, VM ist VirtualBox, die mit NAT konfiguriert ist. Gastbetriebssystem ist Win XP mit installiertem IE7. Mein Ziel ist es, MyApp (läuft auf dem Host) aus dem IE7 (läuft auf dem Gast) zu debuggen.

Der Visual Studio Development Server bindet nur an das Loopback-Netzwerkgerät (dh localhost). Es bindet nicht an die externe IP-Adresse meines Hosts.

Ich habe versucht, vom IE7 aus auf den Gast 10.0.2.2:51227 zuzugreifen (und bestätigt, dass 10.0.2.2 die Gateway-Adresse ist, die ipconfig verwendet), aber es scheint, dass 10.0.2.2 an die externe IP des Hosts gebunden ist, NICHT die Loopback-IP (localhost), das funktioniert also nicht.

Irgendwelche Vorschläge?

7
Ich verstehe nicht ganz, was Sie zu tun versuchen. Testen Sie nur die clientseitige Funktionalität (Layout, Javascript usw.) in IE7 oder versuchen Sie, den Code in der .NET-Webanwendung selbst durchzugehen? James P vor 11 Jahren 1
Ich möchte die clientseitige Funktionalität testen (es gibt jedoch einen bösen Fehler in IE7, daher möchte ich meinen Dev-Server verwenden, um schnelle Änderungen und die Untersuchung des Problems zu ermöglichen). Ich möchte keine Builds auf einen Staging-Server (mit einer auf VM zugreifbaren IP-Adresse) pushen, nachdem ich jedes printf oder ein kleines Experiment hinzugefügt habe. Seth vor 11 Jahren 0
Ich bin offen für eine andere Lösung für mein allgemeines Problem, aber die einfachste Lösung, die ich mir vorstellen kann, ist "einfach auf Host localhost zugreifen zu können, wenn ie7 auf der Gast-VM ausgeführt wird". Vielleicht hat VirtualBox diese Fähigkeit aber nicht? Seth vor 11 Jahren 0
Ich weiß nicht, ob es möglich ist, das zu tun, was Sie möchten, aber der Visual Studio-Entwicklungs-Webserver ist nicht für den Zugriff außerhalb des Kontextes von localhost konzipiert - dafür gibt es IIS. Haben Sie IETester ausprobiert - http://www.my-debugbar.com/wiki/IETester/HomePage? Sie können Websites mit verschiedenen IE-Versionen testen, und ich habe festgestellt, dass sie normalerweise genau mit der gewählten IE-Version übereinstimmen. James P vor 11 Jahren 0

2 Antworten auf die Frage

8
Seth

The simplest solution for me was to use SPI Port Forward on the Host to allow access to my localhost-only service from an external network interface:

  1. Download SPI Port Forward and Run on the Host (no installer, download is a naked exe)
  2. Important: Windows Firewall will ask if SPI Port Forward is allowed to access Public networks. Check the box to allow access from public networks.
  3. Set Local Port to 8888 (or whatever you want), Remote Host to localhost, Remote port to the port of the target service on the host (in my case 51227, as VSDS is running on port 51227), and click "Activate"
  4. Access 10.0.2.2:8888 from the guest.

Note: If 10.0.2.2 doesn't work, run cmd on the guest to bring up a command line, and use 'ipconfig', and use the default gateway address, but VirtualBox currently defaults to 10.2.2.2 for this, so its a safe bet.

It should be noted that this configuration will allow EXTERNAL IP ACCESS TO VSDS, so use with caution... of course, this could be useful if you wanted to debug mobile phone support or something too.

Sie sind mein Retter, ich suchte nach etwas Einfachem wie SPI Port Forward, um meine mobile Site über das Netzwerk über mein mobiles Endgerät zu testen. Diese Lösung funktionierte für mich in Windows 8. Rubens Mariuzzo vor 10 Jahren 0
0
jaume

Although VirtualBox can access the loopback interface on the host (like any other program running on the host), it provides no means for accessing it from a guest OS (which is also the case in other virtualization solutions I know).

If VirtualBox provided access to the host's loopback interface it should create an additional interface on every guest, bound to the loopback interface on the host.

Why this additional interface? Because, on the guest, any traffic sent to 127.0.0.1 would be automatically forwarded to its own loopback interface and not to the host.

I can think of a workaround: Bind Visual Studio Development Server to 10.0.2.2. Like this, your development environment is not accessible from the outside but reachable by the VirtualBox guest (although I read in James's comment above that it may not be possible, I've read recommendations to bind VS to w3p.exe, which seems to work at least on Windows 2003).

As @James points out, I could switch my development server inside VS from VSDS to IIS... but for some reason my app refuses to work in this mode (works fine on the public IIS), but in any case I'd really rather keep my development configuration the same (not have to monkey with VS settings every time I want to test IE7). I wouldn't expect VirtualBox to merge host-localhost<->guest-localhost, I guess i was hoping it would provide a 2nd interface with a standard IP like 127.0.0.2 or something. Seth vor 11 Jahren 0
Schade, dass es nicht funktioniert ... Nur als Randbemerkung: 127.0.0.2 ist ** auch ** Loopback. Der gesamte Bereich 127.0.0.1-127.255.255.254 ist für das Loopback reserviert ... jaume vor 11 Jahren 0