1

As per question, this is what I'd like to achieve:

  • Create a separate Web site node in IIS (7) to host a deployed ASP.NET 4 MVC (and Web API) application. I'd like a separate Web site node instead e.g. of creating an Application in IIS under the default web site node. This is in order to have full rights on application web.config, and not to have restrictions if the Web.config is placed in some subfolder.

  • Say I'm deploying on a development IIS server. Typically the web site node will be located at some URL similar to some.IP.addr.ess/. I'd like instead the web site to be located at an URL like some.IP.addr.ess/some/path/. This is in order to have the web application ready to work also when deployed in a subfolder. That's also because I'd like to deploy another web app on the same server, and have it accessible from some.IP.addr.ess/another/path/.

To clarify my jumbled requirements :) I'd like to have:

  1. One IIS web server instance running on a server, with one IP and possibly a domain name.
  2. Inside the IIS instance, several Web Site nodes, one for each application. An application could be running on ASP.NET MVC/Web API. Another application could be running on PHP. Another could be static HTML pages. Here I'm saying application as a generic term, not necessarily related to an IIS Application.
  3. If the server has an IP address, say 123.123.123.123, each application should be reachable at an URL like 123.123.123.123/MvcApp1, 123.123.123.123/PhpApp2, and so on.

I've searched on the web but probably I didn't use the right terms: I always got articles on how to create applications inside the default node, or virtual directories, etc. And then I found this ASP.NET forum post which seems to say I can't. ** Thanks all

EDIT - Going to the root of the problem, as asked below:
I'd like to refer to the different apps with different URL paths, so e.g. IPaddress/Mvc1, IPaddress/Php2, and so on.
All this is needed for development server, and then for test and staging, not for production. So in the first place there would be no quick need for a domain.
I can live with apps and Web.config in subfolders, or virtual directories, or applications, as long as this does not prevent one each other to work correctly. E.g. an ASP.NET application, next to an ASP.NET MVC with its own routing, and an ASP.NET Web API one, and a PHP one.

superjos
  • 12,189
  • 6
  • 89
  • 134
  • 1
    Your question is rather jumbled. Are you asking if two sites can be at the same ip address, but using two different virtual folders, but have two different hostnames that each resolve as a root inside those paths?? – Erik Funkenbusch Mar 22 '13 at 16:33
  • I agree with @MystereMan. It is essential that you clarify whether you are asking about hosting multiple sites within one folder structure. If you only want the folder structure, that is easy to accomplish using custom routes. – Paul Keister Mar 22 '13 at 17:02
  • Thanks for comments. I added some clarification to the question, please ask more if I'm not yet clear. – superjos Mar 22 '13 at 18:59
  • This question would be much better suited to serverfault.com, as there are many question like this [already](http://serverfault.com/questions/358505/iis7-main-site-with-subdirectories-that-are-also-sites). – Erik Philips Mar 22 '13 at 19:19
  • @Erik yes, probably you are right. I guess some moderator could move it, as I don't think I can. WRT referenced question, my understanding is that if you go with subfolders converted to applications, then you have quite some restrictions on Web.config (things like authentication mode, role provider, etc.). I'd like instead to have *free hands* on each application web.config – superjos Mar 22 '13 at 19:30
  • 1
    @superjos - your understanding is wrong. There is no restriction on authentication mode or role provider or anything like that in a sub-application. There may be considerations you have to take into account, but not restrictions. – Erik Funkenbusch Mar 22 '13 at 19:32
  • You're probably looking for [inheritInChildApplications](http://stackoverflow.com/a/4144263/209259). – Erik Philips Mar 22 '13 at 19:32
  • I see. I know about that `inheritInChildApplications` attribute, but my understanding is that some attributes like `authentication mode` are anyway decided at the root-level Web.config. To say: I understood that if I set the authentication in a Web.config in a subfolder, I receive the infamous *It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level ...*. Am I wrong? – superjos Mar 22 '13 at 20:15
  • 1
    @superjos - That error only occurs if the folder is not set to be an application. If you want a folder to have an app domain of its own, it has to be an application. – Erik Funkenbusch Mar 22 '13 at 21:08
  • ok. So, if I got it right: you can store your web application in a subfolder of (say) default web site node, convert that folder into an IIS application, and let that have its own Web.config with no restrictions on attributes like authentication mode. Is that right? – superjos Mar 25 '13 at 12:04

2 Answers2

1

I think I understand what you're getting at, however, I think you have some fundamental misunderstandings about things.

First, yes, you can have multiple website nodes on a server. And those nodes can all respond to the same IP address, HOWEVER, that will only work when using HTTP 1.1 hostnames, meaning that you have to refer to each site with a different domain name (hostname). Thus, you have:

domain1.com/mvc1 domain2.com/php1

Both domain1.com and domain2.com resolve to 123.123.123.123, but IIS will look at the host name field and determine which site it needs to go to.

If you type in the ip address, 123.123.123.123 then IIS does not know which site you mean, so it uses the default web site. This is key, if there is no hostname, then the default site is always used.

The only option you have, if you wish to use the ip address, is to use application folders within the default site. At least with normal IIS.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Ok. I'm reading this now (after your comments to the question). And yes, I did not get this *irrelevant* (!) detail on the need for different domain in order to let IIS resolve the website node. – superjos Mar 22 '13 at 20:19
0

It's a while since I poked around in IIS, so I'm somewhat rusty, and I don't recall ever coming across your scenario. Here's what I can figure, though:

The IIS docs on creating sites mention the phrase "unique bindings" a lot without making it all that clear what scope that uniqueness is in, but it's logical to assume that it means server-wide, so if your two sites will need to bind to the same URL then it doesn't appear to be possible. The docs also state that a binding can specify a protocol, a port, and a host. Note that there is no mention of a path; you don't seem to be able to bind to anything lower-level. This suggests that a site can be set up to bind to www.somehost.com, but not www.somehost.com/some/path/.

Having said that, it's possible that your problem can be solved by fixing the root of the problem, not the symptom. Rather than asking "how do I set up IIS sites under sub-paths so that I can deploy two applications under one URL?", ask "how do I set up two applications under one URL and not have trouble with rights over the Web.config?"

I know for a fact that you can quite happily deploy multiple applications under sub-paths of one URL because that's exactly what we do at work - we have one application in ASP.NET MVC at www.ourURL.com/somepath, and a legacy ASP.NET Classic app at www.ourURL.com/otherpath. The two applications are separate projects under a single Visual Studio solution, each with their own Web.config.

I can't really be any more helpful without a little more info on the structure of your application and/or details on exactly what problems you're having with Web.config and subfolder-related restrictions; like I said, we deploy like this at work and I've not come across problems with either.

anaximander
  • 7,083
  • 3
  • 44
  • 62