2

First, let me provide you with the outcome I'd like to see.

I unbundle my "application" (pages, code and assemblies) once into a directory. I use the same application (pages, code and assemblies) to drive multiple sites. I apply custom application-specific configuration settings for each site.

Problem is currently IIS takes the web.config from the physical directory. If that's the case, all of my applications would share the same basic configuration. I need to change a value that would normally be in the appSettings section of that web.config and make it specific that site.

Any ideas?

Ajaxx
  • 125
  • 1
  • 3

1 Answers1

1

You can do this by applying the setting in applicationHost.config and wrapping it in a <location path="sitename"></location> tag.

To see an example, use IIS Manager and disable and enable Windows Authentication (or enable/disable). This will leave a stub location tag for you at the bottom of %windir%\system32\inetsrv\config\applicationHost.config.

Just apply whatever setting you want to that section.

You can also use appcmd.exe or Configuration Editor to add the settings rather than using notepad. Whatever method you prefer.

Scott Forsyth
  • 16,449
  • 3
  • 37
  • 56
  • I think this is on the right path, but I appear to be missing something else. So I went to applicationHosting.config and added and that didn't make any difference. I put up a sample aspx page and it failed to see the appSetting. Guess I'll check delegation next. – Ajaxx Dec 17 '10 at 16:33
  • Add the within the location tag too. That should do it. Basically the location tag parallels your level in web.config. – Scott Forsyth Dec 17 '10 at 17:19
  • On further inspection, it would seem the problem is that the Configuration entry points exposed through the .NET runtime do not account for these settings being exposed through IIS 7. Guess I'll punt this question over to stackoverflow. – Ajaxx Dec 17 '10 at 17:23
  • On your comment, you are correct that the tag parallels the tag in web.config. Unfortunately, the tag and tag are peers. So I can't embed my appSettings within the system.web section. It appears that IIS 7 properly interprets things like that, but the CLR doesn't fully honor appSettings stored there (and by honor I mean the APIs aren't really aware of them). – Ajaxx Dec 17 '10 at 17:31
  • Good point. IIS will only allow known configurations. You would have to add it to the IIS Schema for it to accept appSettings. That's in the inetsrv/config/schema folder. You can add another valid schema files. Another option is to add a location tag to the .NET framework's root web.config. It won't upgrade automatically with you when you change frameworks though. Another option is to move your app settings to your database and use a servervariable like HTTP_HOST to differentiate between sites. – Scott Forsyth Dec 17 '10 at 18:27