简体   繁体   中英

IIS7 - Using an ip address and port number will not display a web site home page but using localhost will

Using ASP.Net I did a web site and can load it up in a browser window when pressing the F5 key in VS2010.

On the browser window I noticed VS2010 used an address like this to load the web site home page:

localhost:12345/

If I try to use the ip address for my computer found by using ipconfig to load up the home page,

1.2.3.4:12345

I get an error stating:

Could not connect to 1.2.3.4:12345

If I use:

1.2.3.4

I get the IIS7 default page.

The actual address and port numbers I used in this example are different than those I really used.

Can you tell me why localhost works but 1.2.3.4 does not work?

Can you tell me if I need to do something extra with IIS7 since I never did this before?

A couple of things to remeber. Your computer two types of IP address. The first is a private IP address and the second is a public IP adress. IPConfig will show you your local, private address. Your private address will not be accessible from anywhere outside your LAN.

If you would like to change your websites URL locally from localhost, you need to change your IDE's development settings.

This site has a great tutorial on how to do that.

First things first, the address Visual Studio gives you is a temporal address that corresponds to their development server (Webdev.Webhost or Cassini), this server doesn't allow you to connect outside your computer, that's why localhost:1234 opens your page, but 5.6.7.8:1234 doesn't.

Second, also you seem to have IIS configured, but what you need to do is deploy your site to IIS, here are Microsoft information about deploying your site: http://msdn.microsoft.com/en-us/library/20yh9f1b(v=vs.100).aspx , once deployed, you may create an Application on IIS or a Virtual Directory, for more information you can take a look here: http://technet.microsoft.com/en-us/library/cc772042(v=ws.10).aspx .

Once you have deployed and configured your application or virtual directory, you can access your site like this: localhost/MyVirtualDirectory (assuming you set a virtual directory).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM