Jeremy
Jeremy

Reputation: 46350

IIS/ASP.NET app and subapp: how to use two host names without redirecting?

We have a web application on our server in a directory

 c:\inetpub\wwwroot\myapp

Inside the myapp directory we have a sub directory called mysubapp. mysubapp has its own bin directory, and requires DLLs in the myapp\bin directory

So the directories are as follows:

c:\inetpub\wwwroot\myapp
c:\inetpub\wwwroot\myapp\bin
c:\inetpub\wwwroot\myapp\mysubapp
c:\inetpub\wwwroot\myapp\mysubapp\bin

We currently have IIS set up with host headers so that myapp.mycompany.com points to c:\inetpub\wwwroot\myapp and http://mysubapp.mycompany.com redirects to http://myapp.mycompany.com/mysubapp.

We want mysubapp.mycompany.com to point to c:\inetpub\wwwroot\myapp\mysubapp without having the URL say http://myapp.mycompany.com/mysubapp.

I've tried setting up host headers to point but c:\inetpub\wwwroot\myapp\mysubapp without using a redirect, but when we do this we get an error saying that certain DLL files can't be found, the DLL files not found are the ones in c:\inetpub\wwwroot\myapp\bin. This error makes sense because an application can't locate DLLs outside of it's application directory.

Is there any way we can configure IIS to get this to work?

Upvotes: 1

Views: 1011

Answers (6)

DreamSonic
DreamSonic

Reputation: 1472

A solution not involving url rewriting would be the following:

  1. Assign myapp.mycompany.com and mysubapp.mycompany.com different IP addresses in DNS, but they should map to the same host (Robert explains below how, or use 2 NICs).
  2. Create 2 Web Sites (not Virtual Directories) in IIS.
  3. Map the first one to an IP address of myapp.mycompany.com and point to c:\inetpub\wwwroot\myapp
  4. Map the second one to an IP address of mysubapp.mycompany.com and point to c:\inetpub\wwwroot\myapp\mysubapp
  5. ???
  6. Profit :)

Upvotes: 0

splattne
splattne

Reputation: 104040

If I correctly understand your question, the only working setup that I could imagine is to take the approach you mention (host headers to point but c:\inetpub\wwwroot\myapp\mysubapp without using a redirect) and include the main app's DLLs in your sub folder's bin directory.

Upvotes: 4

devio
devio

Reputation: 37215

If you want to serve /mysubapp under a different domain name, I don't see the point in keeping it under myapp.

Set up the applications as separate web apps, and copy the dlls from myapp to mysubapp. As it is Asp.Net, you may even do some assembly binding magic via the web.config file.

Upvotes: 0

Robert C. Barth
Robert C. Barth

Reputation: 23315

As DreamSonic said, use a different website for each application, with different IP addresses for each. To add more than a single IP to the server, use the advanced button on the Internet Protocol (tcp/Ip) dialog box in Network Properties. In IIS, set the website to respond to the specified IP instead of the default of [All Unassigned]. You don't need two (or more) NIC's.

Other than that, you'll need to do some URL rewriting, which can be a pain because all of the links in your app will need to "fixed" or else you'll eventually end up with the undesirable URL in the client's browser.

Upvotes: 0

Jonathan Parker
Jonathan Parker

Reputation: 6795

Although the answer doesn't take into account host headers the proposed work around in this link might be useful.

Upvotes: 1

Related Questions