IIS Express with Website Project, how to use insid

2019-05-14 17:49发布

问题:

My production environment have a root, and my virtual directory will be at /brazil folder inside the root.

When I convert my website project(not web application), that works correctly with Cassini at /brazil since my website folder is brazil, IIS Express put the site at root, how can I change this?

回答1:

I'm seeing similar problems with IIS Express with web applications. From what I'm seeing, IIS Express actually allows you to define a folder in the 'Project Url' field, but then when launching it generates 2 websites, one with the folder and another for the root application. Problem with this is that it is using the same folder for both which brings web.config inheritance issues.

My solution was to go edit the hosting file and change the physicalPath for the root virtual directory to an empty folder in my system

For example:

<site name="MySite1" id="1">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2010\MySite1\MySite1" />
    </application>
    <application path="/ssd">
        <virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2010\MySite1\MySite1" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:59473:localhost" />
        <binding protocol="https" bindingInformation="*:44302:localhost" />
    </bindings>
</site>

To this:

<site name="MySite1" id="1">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\TEMP\New folder" />
    </application>
    <application path="/ssd">
        <virtualDirectory path="/" physicalPath="C:\VisualStudioProjects\2010\MySite1\MySite1" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:59473:localhost" />
        <binding protocol="https" bindingInformation="*:44302:localhost" />
    </bindings>
</site>