WebMatrix: how to change site’s folder name

You might find yourself in a situation where you want to change the project and directory name in WebMatrix – to keep your filesystem and repo clean, maintain standardized naming of projects or because EmptySite does not really express a lot about what the page is all about.

While you can easily change the project name from WebMatrix environment (right mouse click on project and then choose Rename), this will not change a directory name in filesystem.

WebMatrix: directory name

WebMatrix: directory name

To change also the directory name, we need to go deeper in IIS Express settings. The configuration file is located in:

%userprofile%\Documents\IISExpress\config\applicationhost.config

(e.g. c:\Users\buli\Documents\IISExpress\config\applicationhost.config)

and contains configuration for IIS Express and sites. Now find the <site>...</site> entry for your site:

Now you can change the physicalPath attribute for site’s virtualDirectory and the next time WebMatrix is started, the new path will be used instead of old one. Currently changing this folder from WebMatrix’s GUI is not possible.

Do not change the site’s name attribute, as it will break some foreign key relation and you might not be able to open the site at all. It’s not necessary for the change of a project’s name and folder.

This little trick shall help you keep your folder structure clean and easier to mantain 🙂