Thursday, 20 September 2012

Adding sub-sites in IIS7

The title reflects my limited understanding of what I was trying to do in IIS7. I had a web site which was under a domain name which needed to access a web service hosted on the same machine. Since I wanted to use ssl for both and I had a certificate for the top level site, I wanted to host the web service under the other site somehow.
I tried adding it as an application under the main site and pointed to the relevant directory and after the usual fun and games (usually needing to add permissions for \iis_iusrs and iusr to the relevant directories) I was still getting errors and it took a while to spot that the complaint was "assembly X could not be found". What I eventually noticed was that assembly X was referenced by the top level site so why was my web service attempting to load it? It didn't take long to realize that the web service was inheriting the web config of its parent application even though it was in a physically separate directory. I then found good old Rick Strahls blog post here: http://www.west-wind.com/weblog/posts/2007/Aug/11/IISASPNET-Settings-and-Virtual-Directory-Inheritance which identified the workaround as adding a inheritInChildApplications="false"
> tag around system.web and system.webserver elements in the parent site's web config.This indeed stops the inheritance but then I had a follow-on problem with a 500.22 error which detects an invalid config setting for integrated pipeline mode. This is a strange error since all I added was a (valid) location tag but then found another post here: http://runtingsproper.blogspot.co.uk/2010/04/solved-iis7-validateintegratedmodeconfi.html which describes the workaround as removing any httphandlers from the system.web section. I don't know why this only happens with the location tag, perhaps the invalid code is ignored if the config is inherited (since it might be inherited into a classic application pool?) but anyway, in my case, I didn't need the module so I simply removed it and the site came back to life.
Post a Comment