IIS 7.0(IIS Express)设置

IIS 7.0 (IIS Express) Setup

给定以下设置:

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

我们有一个业务需求要从

http://web

http://web/Snapshot1

http://web/Snapshot2

...

http://web/Snapshotn

我想知道是否有一个简单的方法来解决这个问题,只需修改 routconfig 或类似的(请注意,每个快照将有一个全新的 "web" 和 "modules" 副本.

我尝试将 "project Url" 设置为“http://Web/Snapshot1”并为 "Snapshot1" 添加一个 RouteConfig.cs 条目

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

这会丢弃所有 js、样式表和图像的相对路径;所以我不确定这是否是正确的方法。同样为了让生活更有趣,由于公司政策,我们在任何地方(包括开发箱)都没有管理员权限;所以玩 IIS 不是一种选择(除非你知道一种方法?);我仅限于 IIS Express

更新

按照建议,我更新了 IIS Express 配置; 不幸的是,以下设置会导致 URL 重写,其中删除了快照名称

    <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>

所以这里的 Crush 很有帮助; 这是我所做的,所以我可以解决我的 URL 要求(如果用旧的 IIS 测试这个会非常简单;哦,好吧......只要它可以完成我猜):

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

在上面的每一个下面我会部署不同的模块(但是,URL 的根不是 "Website",而是 "Website/{somename}/modules";

所以像这样:

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

在 IIS - Express 配置文件 (applicationhost.config) 中,我创建了以下内容,一切都神奇地发生了:

    <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>