Search code examples
asp.net-mvciisweb-configvirtual-directoryappsettings

ASP.Net MVC and IIS 7 using Virtual Directory to a config file


I have an MVC application that is shared by many websites in IIS, but each needs it's own app settings. In my Web.Config, I have the following:

<appSettings file="Config/AppSettings.config" />

Then, in IIS I set up virtual directories for each site's separate file.

To my astonishment, this did not work, but did when I tried it without using a virtual directory. Any ideas?

I saw this post IIS Config file in virtual directory

which was very similar, but did not offer the response I was looking for.

I'm also open to other ways to accomplish the same thing; if such a solution exists.


Solution

  • It's not possible to use a virtual directory (or even files outside of the current website; only the current folder, or a sub-folder) in 'appSettings file=...'.

    One possible way to share setting across projects would be to do it at build-time - either by coping it in, or using a Linked File in VS to have it copied to the folder on publish.

    If you really need this functionality on the server, you could try (though I can't say how well it would work) a Junction.