- 8 Week Game
- About Me
- Quick Ref
Posts Tagged asp.net
We recently had an issue setting a .net microsite live off the back of an existing domain, hosting another .net site.
This was due to the web.config being inherited to the child- we would be hit with errors like this;
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly ‘UrlRewritingNet.UrlRewriter’ or one of its dependencies. The system cannot find the file specified. (d:ProjectsVSAspDotNetFaqProjectWebsiteweb.config line 89)
Line 88: <httpModules> Line 89: <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter"/> Line 90: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> Line 91: </httpModules>
This is because a module was defined in the parent site which doesn’t exist in the child, but because it’s inheriting it still tries to load it. We would also get errors complaining that modules have already been defined.
I tried initially, manually adding <remove name=”blah” /> to the child web.config to remove the entries in the child web.config it thought were defined twice, but after putting in about 10 of these and it still not working it started to get a bit ridiculous!
The trick, we found on google (How to disable web.config Inheritance for Child Applications in Subfolders in ASP.NET?) is to stop the web.config from inheriting in the top level web.config;
<location path=“.“ inheritInChildApplications=“false“>
This stops anything being migrated down to the children, allowing you to have your full web.config in the child site, unaffected by the parent! — Make sure you don’t put this around anything else though; just the system.web section!