Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my IIS virtual directory work with http://localhost but not http://computername?

I have been given the task of adding functionality to an existing IIS 6.0 website. To do it, I have built an ASP.NET MVC application. It works fine when deployed as it's own site, but doesn't seem to work when I try to deploy it as a virtual directory on the actual site where it needs to live.

The server name is CWEBSERVER, and the IP is 192.168.1.11. From looking at IIS Manager, this is the site structure:

(Default Website) (root)
  - PRODUCTION (vDir)
  - CONTENT (not a vDir)
  - DATAFOLDER (vDir, contains MVC app, just added by me, not working)

The strange thing is that when I type the following URL's from a browser on the server it works:

http://localhost/DATAFOLDER/account.aspx
http://127.0.0.1/DATAFOLDER/account.aspx
http://192.168.1.11/DATAFOLDER/account.aspx

The following URL (which is the one that I NEED to work) doesn't:

http://CWEBSERVER/DATAFOLDER/account.aspx

The error I am getting is "The resource cannot be found."

After looking closer, I realized that requests to http://CWEBSERVER are going to the PRODUCTION vDir, but calls to http://localhost or http://192.168.1.11 are going to the root of the website. I guess this is something setup by the original site designer. I am not sure how to change this setup, but I don't think I can change it anyway because there are actually a ton of other directories that would be affected. The other thing I wanted to point out is this: the CONTENT folder is accessible by going to http://CWEBSERVER/CONTENT. This is really weird since I thought that the http://CWEBSERVER pointed me to the root, so I wouldn't think that the "/CONTENT" would actually be able to get to the CONTENT folder.

Now my problem is this: how do I get my DATAFOLDER accessible via http://CWEBSERVER/DATAFOLDER? I would think that I should just put the DATAFOLDER vDir inside of the PRODUCTION vDir. I tried it, and using the localhost or IP this is still accessible via:

http://localhost/PRODUCTION/DATAFOLDER/account.aspx
http://127.0.0.1/PRODUCTION/DATAFOLDER/account.aspx
http://192.168.1.11/PRODUCTION/DATAFOLDER/account.aspx

When I use CWEBSERVER, however, it still fails:

http://CWEBSERVER/DATAFOLDER/account.aspx

The error is still "The resource cannot be found.". Can anyone shed some light on this? Specifically, I have these questions:

  1. How does http://localhost go to the root, and http://CWEBSERVER go to the PRODUCTION vDir? Where can I change this setting?
  2. Why would "http://localhost/PRODUCTION/DATAFOLDER/account.aspx" work but not "http://CWEBSERVER/DATAFOLDER/account.aspx"?

The accepted answer to this question (whom bounty will be awarded to) will need to be able to make it so I can access http://CWEBSERVER/DATAFOLDER/account.aspx. Thanks!

like image 770
skb Avatar asked May 22 '09 14:05

skb


People also ask

Why is my local website not working in IIS?

Make sure the website has been started in IIS: In the left pane of IIS Manager under "Sites", select the appropriate site. If your site is configured under the "Default Web Site", select that one. In the right pane under "Manage Website", there are "Start" and "Stop" links.

How do I access IIS website from outside using public IP address?

Go to Start → Administrative Tools → Internet Information Services (IIS) Manager. 3. In the Connections pane of IIS, expand the Sites and select the website which you want to access via IP address.

How do I find virtual directory in IIS?

In the Internet Information Services window, expand server name (where server name is the name of the server). Right-click the Web site that you want (for example, Default Web Site), point to New, and then click Virtual Directory.


1 Answers

Most likely you have IIS bound to the IP address only. Go to IIS Manager, then go to properties on the website. Then, from the Web site tab, go to properties.

Add a identity for that host header value.

If necessary you can add multiple bindings.

update

I think I know what you want now. From IIS Manager, expand your default website. Then right click on the Production virtual directory and pick "Create Virtual Directory". Call this new one DATAFOLDER. Then tie this to the existing location on your file system.

I really think you need to clean this up a bit. The first thing I would do is decide how everything is really supposed to be accessed. In other words, when they type http://www.mysite.org/ What is that supposed to be? If it's the PRODUCTION directory, then Create a new site and point it to the PRODUCTION directory, then create your DATAFOLDER virtual app under it.

like image 130
NotMe Avatar answered Oct 23 '22 23:10

NotMe