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

亡梦爱人 提交于 2019-11-28 20:50:55

问题


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?


回答1:


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.




回答2:


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)




回答3:


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




回答4:


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!




回答5:


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" :

  1. The adress is the IP adress of your DEV machine.
  2. 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.



回答6:


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




回答7:


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



来源:https://stackoverflow.com/questions/1730280/accessing-asp-net-development-server-from-another-pc-on-the-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!