views:

3558

answers:

3

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!

+1  A: 

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.

Chris Lively
Thanks for the tip. When I look at the list of identities, all I see is "Default" for port 80. I also added a bunch more info that I found. THANK YOU FOR YOUR HELP! I AM VERY GRATEFUL FOR ANYTHING YOU CAN TELL ME.
skb
Thanks for your update, Chris. I tried to add the DATAFOLDER vDir under the PRODUCTION vDir, but for some reason I am still unable to access it using www.mysite.org/DATAFOLDER. localhost/PRODUCTION/DATAFOLDER however works. I think it might help if I could first figure out why www.mysite.org gets directed to PRODUCTION vDir, but localhost goes to the root of the website. Maybe if I could understand this difference, I could see what is making things still not work. Any ideas?
skb
You really should start over with your bindings. It sounds like a virtual dir for PRODUCTION was established when it shouldn't have been.Start with a new site, give this one the www.mysite.org binding and point it to your PRODUCTION directory. Then add a virtual directory underneath it that points to your datafolder.
Chris Lively
Looks like I was way off, and there were actually TWO sites on my server. Each with different bindings. When I set the vDir up on the CORRECT site, it worked. Since you helped me the most, I am awarding you the bounty. Thanks!
skb
I'm glad it worked out. Thanks.
Chris Lively
A: 

add '192.168.1.11 cwebserver' to %Windir%/system32/drivers/etc/hosts

balint
Thanks, but this is not the problem. It needs to be accessible from lots of other machines as well.
skb
A: 

Do as Chris Lively said and add more bindings for the other host names or add a new site with settings to the same content. IIS responds by seeing the host header information and if you only have Default Web Site with a single binding to port 80 it won't handle all the possible headers.

If the name is internal to your company like the machine name or an internal DNS entry you might get away with letting the default binding do the job. If it doesn't work in testing add a binding for that situation (CWEBSERVER or mysite.org). Test it with and without the www if you care about it working both ways.

There isn't much downside to adding multiple "sites" in IIS for the same content. For example you could have

mysite.org pointed to /PRODUCTION/DATAFOLDER/index.html

and

marketingsite.com pointed to /PRODUCTION/DATAFOLDER/index.html

Then you can do things like have different SSL settings and so on. On my web server nothing hits Default Web Site unless something goes wrong (like I set up a new external IP address and need haven't yet modified the bindings).

Pick your poison but essentially you just have to add settings in IIS until it handles all the possible addresses the way you want it to.

pplrppl
I am trying to do the opposite of what you refer to. I don't want multiple "sites" for same content, I want disparate content "merged" into one site.I have a default site. This site has a PRODUCTION vDir which "www.mysite.org" points to (BTW, I can't figure out how this vDir ends up being the "root" of "www.mysite.org" but for "localhost" it is not, I don't see a setting for this for the vDir or the site). I don't care about localhost, I just need to have mysite.org/DATAFOLDER point to a separate vDir. Is this possible?
skb