asp.netiisweb-configiis-expressvirtual-directory

configure web.config to point to a rootfolder


Could you please help me configure web.config, so that IIS express resolves all URLs, beginning form my physical root folder.

For example I want all my web files in Visual Studio to have "webroot" folder:

C:/dev/myWebMvcApplication/webroot/app/index.html

Where: myWebMvcApplication is the folder for my solution, [.sln] and webroot is a physical folder containing all my files; so that, all URLs could look like

/localhost:port/app/index.html

and not like

/localhost:port/webroot/app/index.html

Solution

  • As of IIS7 changing sites within your server is generally done now in the sites section of applicationHost.config.

    <sites>
        <site name="Blah Blah" id="1">
            <application path="/" applicationPool="DefaultAppPool">
                <virtualDirectory path="/" physicalPath="C:/dev/myWebMvcApplication/webroot" />
            </application>
            <bindings>
                <binding protocol="HTTP" bindingInformation="*:80:" />
            </bindings>
         </site>
    </sites>
    

    I am assuming you are are talking about changing the root of your webserver so that all applications under your solution share the same base URL. Please let me know if this is an incorrect assumption.