Accessing ASP.NET Development Server from another pc on the network - asp.net

I would like to test my web app in other browsers. I have installed Virtual PC to do just that. the ASP.NET development server does not allow remote connections so the virtual pc (another computer on the network) cannot access the website.
I found this post that was started but there was no solution.
I understand that using localhost will not work. I heard about using the machines ip, but how do I get that correct ip? Look at my lynksys router admin?
If I were to get as far as getting my IP, im sure that the asp.net dev server does not allow remote connections. How do I enable it to do so?

The answer is: no(*). You cannot access the ASP.NET Development Server on one machine from another, even if you open the Windows firewall TCP port.
From the MSDN article "Web Servers in Visual Web Developer":
It is specifically built to serve, or run, ASP.NET Web pages under the local host scenario (browsing from the same computer as the Web server).
In other words, the ASP.NET Development Server will serve pages to browser requests on the local computer. It will not serve pages to another computer. Additionally, it will not serve files that are outside of the application scope.
(*) You'll have to run your site from your locally installed IIS... or do the nice hack using some freeware described in this blog post:
iPhone Accessing the Visual Studio ASP.NET Development Server
Use SPI Port Forward to accept the device connections do the following:
Set "Local port" to the port number the device will connect on, I usually use 8080 out of habit
Set "Remote host" to localhost
Set "Remote port" to the ASP.NET Dev Server Port
Click the "Activate" button to start accepting connections
(note: make sure you've started the program with admin rights)

I'm making some guesses about your setup here so bear with:
If your virtual machine is XP Professional, Vista Business, Windows 7 Professional or better, then you should be able to run IIS locally on the development machine and access that webserver from another machine which is on the same network via the virtual machine's name.
Likewise, if you're doing development on a real machine and would like to use different virtual machines to access the web application, you should make sure that you have IIS installed, create a new website in IIS and you should be to browse to the web application via machine name from your virtual machines.
Either way, don't try to use the builtin web server from Visual Studio, just publish your site to IIS and work with it that way.
Good luck and hope this helps some.

Setup a portforwarding using RINETD
Deatils here: http://blog.waynehartman.com/articles/218.aspx

Another answer if you don't want to use IIS (or tunnels): https://stackoverflow.com/a/12008223/1552178
Use fiddler or similar on your host - set your browser on the client
VM to use the proxy then just use localhost:dev_port as usual on the
client.
All requests from the client goto the proxy on your dev machine which
routes to localhost on the dev machine and the ASP.net dev server
thinks the request is from your dev machine!

I am answering this old question to help people to make it work without IIS.
1. First Step
You have to download Fiddler.
Once Fiddler is downloaded and installed, open it.
Go in Tools-> Fiddler Option-> Connection tab-> And check "Allow remote computers to connect" :
Restart Fiddler.
2. Second Step
After this, in the other PC on the network OR the VM, open internet explorer-> Internet Options-> Connection Tab-> Lan Settings-> Check "Use a proxy server for your LAN" :
The adress is the IP adress of your DEV machine.
And put the port 8888
Now, you can access the ASP.NET Web Server from another PC on the network (maybe you have, more config to do, like firewall, unrestricted port, etc, but this is a good start) !
To access it -> http://localhost.:54814
Don't forget the additional point after "localhost" ! (Overwrite the local localhost)
The port, "54814" in my case, is the ASP.NET Web Server port.
NOTE :
To test if the proxy work, you can try this : http://localhost.:8888
Maybe I forgot to point out some configurations, but it always depend of the network infrastructure.

Working solution for Linux
This should work if you're running an ASP.NET Dev Server on Windows in a VM or on another host and you want to access it from Linux
On Windows machine
For some reason you cannot connect directly to the ASP.NET dev server port, you need to proxy it locally first:
Use SPI Port Forward to accept the device connections do the following:
Set "Local port" to the port number the device will connect on, such as 8089
Set "Remote host" to localhost
Set "Remote port" to the ASP.NET Dev Server Port
Click the "Activate" button to start accepting connections
(note: make sure you've started the program with admin rights)
On Linux machine
Locally forward localhost port 8089 to the windows IP (replace GUEST_IP_HERE with the correct ip):
iptables -t nat -A OUTPUT -m addrtype --src-type LOCAL --dst-type LOCAL -p tcp --dport 8089 -j DNAT --to-destination GUEST_IP_HERE:8089
iptables -t nat -A POSTROUTING -m addrtype --src-type LOCAL --dst-type UNICAST -j MASQUERADE
This is needed because the dev server specifically looks for localhost in the request and will not respond to http://GUEST_IP_HERE:8089 from the host

I tried the following that i expected to enable current .net framework [ core / x-platform ] 6.0 release provided asp.net development web server access at least from other machines on local subnet w/o needing to use any 3rd party software enable the port forwarding/proxy to localhost only exposed web server.
I was able to launch the asp.net development web server from windows wsl [ windows subsystem for linux ] distro session and access it using the windows host wi-fi adapter ip address but not from another machine on my subnet, e.g. a vmware linux install operating in bridge mode. It did work if i switched vmware linux install to nat mode.
Any thoughts on why this doesn't allow other hosts access as i expected it would?
netsh interface portproxy add v4tov4 listenport=<tcp port for non-localhost access allowed/enabled in windows firewall> listenaddress=0.0.0.0 < or windows wired/wifi ipaddress > connectport=<tcp port for localhost access to asp.net development web server> connectaddress=localhost
e.g. netsh interface portproxy add v4tov4 listenport=4430 listenaddress=0.0.0.0 connectport=7146 connectaddress=localhost & netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=5038 connectaddress=localhost
netsh interface portproxy show all
// for %i in ( 4430, 8080 ) do ( netsh interface portproxy delete v4tov4 listenport=%i listenaddress=0.0.0.0 )
netsh advfirewall firewall add rule name="Asp.Net Development Web Server Listeners to Expose" dir=in protocol=tcp localport=<csv list of tcp ports allowed/enabled in windows firewall> profile=private|any remoteip=localsubnet|any action=allow [ enable=yes ]
e.g. netsh advfirewall firewall add rule name="Asp.Net Development Web Server Listeners to Expose" dir=in protocol=tcp localport=4430,8080 profile=private remoteip=localsubnet action=allow
netsh advfirewall firewall show rule name="Asp.Net Development Web Server Listeners to Expose" [ or wf.msc | inbound rules ]
// netsh advfirewall firewall delete rule name="Asp.Net Development Web Server Listeners to Expose"

year 2022:
After trying everything on asp.net core .NET 6 side and failed I have found
https://mitmproxy.org/
mitmproxy --mode reverse:https://localhost:7053 --ssl-insecure
covers my use case.
on phone and other devices access with http://{your-pc-ip}:8080

Open a command prompt and type; "ipconfig" this will give you your machines IP address.
If you disable your firewall (for the asp.net dev port at least) you should be able to type into the virtual PC's browser http://192.168.1.3:3243/default.aspx

Related

Accessing a local website from another computer inside the local network in IIS 10

On my computer I have deployed my web site on IIS. If I access this website locally with :8080 works perfect, but when I try to access this site from another machine or my Android phone I get 'The site can't be reached. my_ip_address took too long to respond ERR_CONNECTION_TIMED_OUT –' this error.
I have tried solutions from this question, but nothing worked for me. Need some help!
There are few factors which can affect the accessibility of the site hosted on your local computer:
Is the client machine (including your phone) in the same network as the Server (In this case your site)
Is the firewall configured to allow connections on port 8080
Have you tried accessing the server using the IP Address. For e.g. http://192.168.0.1:port
Steps to isolate
Ping the server Ip from the client machine and see if it is able to connect to it.
ping 192.168.0.1
If the above fails, then I would assume that you are not on the same network. If it succeeds then check if the port is open.
You can also use nmap to see whether the ports are open or not
nmap -p 8080 kaushal.com
If the above fails, then open the port in your Firewall configuration and then try again.
Try this and share the results.

Meteor app on local network

I'm learning how to use Meteor by following the tutorial. I'm aware that Meteor automatically hosts the app to both localhost and my IPv4 address (in this instance, 192.168.1.100). When I visit 192.168.1.100:3000 on the computer it's hosted from, the app works fine, however it won't load on any other devices that access 192.168.1.100:3000 from the local network.
I've read the following answers:
Accessing meteor server on LAN
Accessing Meteor local web server from another local device on Mac 10.8
Meteor - accessing the app using public ip
How to run meteor server on a different ip address?
Start Meteor server and let other computers access it
And none of them worked for me. It may be because I'm running Windows. If that's the case, can anyone help on how to host the app on the local network?
There's a number of reasons why you may not be able to
try opening the port
netsh advfirewall firewall add rule name="Meteor 3000" dir=in action=allow protocol=TCP localport=3000
if connecting via wifi, then routers often disallow connections to other devices on the network, check router settings

NETSH port forwarding from local port to local port not working

I'm trying to use NETSH PORTPROXY command to forward packets sent to my XP PC (IP 192.168.0.10) on port 8001 to port 80 (I've a XAMPP Apache server listening to port 80).
I issued the following:
netsh interface portproxy add v4tov4 listenport=8001 listenaddress=192.168.0.10 connectport=80 connectaddress=192.168.0.10
Show all confirms that everything is configured correctly:
netsh interface portproxy show all
Listen on IPv4: Connect to IPv4:
Address Port Address Port
--------------- ---------- --------------- ----------
192.168.0.10 8001 192.168.0.10 80
However, I'm not able to access apache website from http://localhost:8001. I'm able to access through the direct port at http://localhost as shown below.
Additionally, I've also tried the following:
1. Access the Apache website from a remote PC using the link: http://192.168.0.10:8001. Firewall turned off.
2. Changing listenaddress and connectaddress to 127.0.0.1.
Without further information, I can't find a way to resolve the problem. Is there a way to debug NETSH PORTPROXY?
Note: By the way, if you're wondering why I am doing this, I actually want to map remote MySQL client connections from a custom port to the default MySQL Server port 3306.
I managed to get it to work by issuing:
netsh interface ipv6 install
Also, for my purpose, it is not required to set listenaddress and better to set connectaddress=127.0.0.1, e.g.
netsh interface portproxy add v4tov4 listenport=8001 connectport=80 connectaddress=127.0.0.1
If netsh's port proxying is not working as expected, then you should verify the followings, preferably in that order:
Make sure the port proxy is properly configured
Start or restart the related Windows service
Ensure support for IPv6 is installed
Make sure the port is not blocked by a firewall
Make sure the port proxy is properly configured
This might seems to be trivial, but just in case, take the time to review your configuration before you go any further.
From either a command prompt or PowerShell prompt, run the following command:
netsh interface portproxy show all
The result should look something like this:
Listen on ipv4: Connect to ipv4:
Address Port Address Port
--------------- ---------- --------------- ----------
24.12.12.24 3306 192.168.0.100 3306
24.12.12.24 8080 192.168.0.100 80
Carefully review those settings. Make sure that you can indeed connect to the addresses on the right side of that list, from the local computer. For example, can you locally open a web browser and reach 192.168.0.100:80? If the protocol is not HTTP, then use telnet: telnet 192.168.0.100 3306 (see here for how to install the Telnet client on Windows).
Then, are the values on the left side correct? Is the IP address valid for your machine? Is that the port number you are trying to connect to, from the external machine?
Start or restart the related Windows service
On latest versions of Windows, netsh's port proxying is handled by a Windows service named "IP Helper" or "iphlpsvc". Proxying will obviously not work if that service is stopped. I have also faced situations that turned out to be resolved by restarting that service.
To do that in latest versions of Windows:
Open the Task manager, then go to the Services tab.
In the "Name" column, find the service named either "iphlpsvc" or "IP Helper".
Right click on that service, then select Restart. If restart is not available, then the service is probably stopped, and actually has to be started, so select Start.
On previous versions of Windows, look for Services in Administrative Tools, inside the Control Panel.
Ensure support for IPv6 is installed (older releases of Windows only)
On earlier versions of Windows (that is Windows XP, for sure, upto some early releases of Windows 10, apparently, though this is not clear), netsh's port proxying feature (including for IPv4-to-IPv4 proxys) was actually handled by a DLL (IPV6MON.DLL) that was only loaded if IPV6 protocol support was enabled. Therefore, on these versions, support for the IPv6 protocol is required in order to enable netsh's port proxying (see Microsoft's support article here).
From either a command prompt or PowerShell prompt, run the following command:
netsh interface ipv6 install
If you get an error indicating that command interface ipv6 install was not found, then it means that you are using a recent release of Windows, in which netsh's IPv6 support is implicit and cannot be disabled.
Make sure the port is not blocked by a firewall
A local firewall may potentially block the port even before they reach the IP Helper service. To make validate this hypothesis, temporarily disable any local firewall (including Windows' native firewall), then retest. If that works, then simply add a port exclusion to your firewall configuration.
I have the problem with you. I have solve it just now. There is a Windows Service named "IP Helper" that supplies the funcions tunnel connections. You should ensure it has been started.
You must Run Command.exe as Administrator first, by right-clicking the Command Prompt icon and choosing Run as Administrator. You will asked to confirm.
Paste your netsh Command in the command.exe window and press Enter.
If no error message is shown, the command worked.
In your web browser go to http://your-up:8001 to see it works.
The Windows Event Log might have information to help find the cause of a failure.

Connecting to Windows localhost (IIS) from another computer

I have a Windows Vista laptop running IIS7 for its localhost. On this machine, I can successfully navigate to:
"http://localhost"
"http://127.0.0.1"
"http://mycpuname"
However, I cannot access this localhost website from another computer on the same network. Ideally I would be able to visit "http://mycpuname" (so that I can hard-code a connection), but at this point I might settle for the IP address of the machine (http://192.000.000.xyz)
I've seen similar questions asked here and elsewhere on the internet... but none of the posts seems to fix the issue for me.
Things I've tried:
- adding exceptions to Windows Firewall to allow TCP ports 80 and 8080
- disabling Windows Firewall entirely
- running the "netsh" commands in this post
Additionally, I am looking at the IP address on the Windows laptop by running "ipconfig" from the command prompt. Oddly enough, trying to access "http://192.000.000.xyz" from the Windows laptop doesn't seem to work...
I have also tried restarting IIS and restarting my machine.
Help?
Go to windows firewall with advanced security, inbound rules and check and see if world wide web services is enabled. I had this same issue, and this fixed it for me.
are you binding to 127.0.0.1? run below command
netstat -an |findstr :80 |findstr LISTEN
if it shows 127.0.0.1, you need change IIS listen to 0.0.0.0
Try netstat -na - it will show you what IP addresses your web server is listening on.
If it's only listening on 127.0.0.1, the loopback, you will have to re-configure the web server to listen on all addresses/interfaces (usually either *.*.*.*, or 0.0.0.0 in some config file, or just some drop-down in some windows dialog somewhere).
If, on the other hand, netstat tells you the web server is listening on *.*.*.* or 0.0.0.0, i.e. all interfaces, then you have to figure out what's blocking the traffic - it's either the local firewall, or something on the path between the two computers.
If you want to access your website from any other computer on your local network then you need to simply type your network IP and port. If you want to access it from internet then you need to configure your IP.

Access localhost on the main machine from VMware Workstation 8 for ASP.NET development test

I run an ASP.NET Development Server (that came with MS Visual Studio 2010) on my Windows 7 machine. I'm currently developing an ASP.NET C# web application and to test it on Windows 7 machine I need to navigate my web browser to an address like this:
http://localhost:59215/Default.aspx
I also have the VMware Workstation 8 installed on that Windows 7 with other OS as virtual machines. I need to try to load my web app from those virtual machines, but when I type the above address there I get "Cannot display page" error in a browser. Note that I can access internet from a virtual machine itself, but for some reason localhost on the main machine is not accessible.
Any ideas how to set this up?
OK, I got it!
For those who're interested, here's how:
Say, my developement URL on the host computer is:
http://localhost:59215/Default.aspx
Download this util, called tcpTrace and run it on a host machine. When it starts configure it as follows:
Listen to port #: 80
Destination Server: localhost
Destination Port #: 59215 (which will be different in your case)
Click OK and let tcpTrace run on the host computer.
On the virtual machine navigate the browser to the IP address of the host computer, for instance in my case:
http://192.168.0.4/Default.aspx
and it will work!
PS. To get an IP address on the host machine, run ipconfig there (in a command prompt window). Your IP will be presented in the "IPv4 Address" line for network you're connected on.
PS2. Also my Windows 7 (host) doesn't come with any third-party anti-virus or firewall. It has a built-in Windows firewall and MS Security Essentials as an AVP. So if your setup is different one needs to open the incoming port 80.
PS3. Speaking of the VMWare Workstation, the virtual machine's network adapter setting is set on "NAT: Used to share the host's IP address" as it came out-of-box when you install it.
localhost is the local machine (to the OS).
I'm not sure if the VS dev server will allow external connections, you may want to install IIS - either way, you'll have to open up the Windows Firewall to allow external connections.
I'm no VMWare user but each OS will have its own IP address(?) - and that's how you'd connect to the Windows 7/IIS image. http://the.ip.address.of.the.win7.image/

Resources