Search code examples
c#asp.net-mvcasp.net-mvc-4iis-7iis-express

IIS 7.0 (IIS Express) Setup


Given the following setup:

Website: "Web"
Modules: Web/Module1, Web/Module2/, ...
URL: http://web 

we have a business requirement to go from

http://web

to

http://web/Snapshot1

http://web/Snapshot2

...

http://web/Snapshotn

I'm wondering if there's an easy way to go about this, with simply modifying routconfig or similar (please note, there will be a brand new copy of "web" and "modules" per snapshot.

I tried Setting the "project Url" to "http://Web/Snapshot1" and add a RouteConfig.cs entry for "Snapshot1"

routes.MapRoute(
                name: "Snapshot1",
                url: "Snapshot1/{controller}/{action}/{id}",
                defaults: new { controller = "home", action = "Index", id = UrlParameter.Optional }

This throws off all the js, stylesheet, and images relative paths; so I'm not sure if this is the right approach. Also to make life more interesting, due to company policies, we do not have admin privileges anywhere (including dev boxes); so playing with IIS is not an option (unless you know of a way?); i'm limited to IIS Express

Update

As per the suggestion, I updated my IIS Express config; Unfortunately, this following setup causes a URL rewrite where the snapshot name is removed

    <site name="Web-Site" id="1">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="H:\Data\My Documents\My Web Sites\Web-Site" />
        </application>
        <application path="/snapshot1" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="c:\abc\def\Web" />
        </application>
        <application path="/snapshot1/WebShell" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="c:\abc\def\Web\Modules\Shared\WebShell" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation="*:2222:localhost" />
        </bindings>
    </site>

Solution

  • So Crush here was very helpful; Here's what I did so I can resolve my URL requirements (would've been super simple to test this with good old IIS; oh well.... as long as it can be done I guess):

    http://website/Prod
    http://website/snapshot1
    http://website/snapshot2
    http://website/dev
    http://website/staging
    

    underneath each of the above I would have different modules deployed (however, the root of the URL is not "Website", rather it's "Website/{somename}/modules";

    So something like:

    http://website/Prod/Members
    http://website/Prod/Loans
    http://website/Prod/Blogs
    http://website/Prod/Documents
    http://website/Prod/Media
    
    http://website/snapshot1/Members
    http://website/snapshot1/Loans
    http://website/snapshot1/Documents
    http://website/snapshot1/Media
    
    http://website/snapshot2/Members
    http://website/snapshot2/Loans
    http://website/snapshot2/Media
    

    In IIS - Express config file (applicationhost.config), I created the following and everything magically happened to work:

        <site name="website-name-or-whatever-the-heck-you-want-it-2b" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="path to some snapshot selector" />
            </application>
            <application path="/snapshot1/Members" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\...\path to members" />
            </application>
            <application path="/snapshot1/Loans" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\...\path to Loans" />
            </application>
            <application path="/snapshot1/Blogs" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\...\path to Blogs" />
            </application>
            <application path="/snapshot1/Documents" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\...\path to Documents" />
            </application>
            <application path="/snapshot1/Media" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath=Media />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:5260:localhost" />
            </bindings>
        </site>