Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
I think this is on the right path, but I appear to be missing something else. So I went to applicationHosting.config and added <location path="sitename"><appSettings><add key="test" value="blah" /></appSettings></location> 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 <system.web></system.web> within the location tag too. That should do it. Basically the location tag parallels your <configuration> level in web.config. –  Scott Forsyth - MVP 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 <location> tag parallels the <configuration> tag in web.config. Unfortunately, the <appSettings> tag and <system.web> 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 - MVP Dec 17 '10 at 18:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.