As I was working with my site which had two virtual directories hosting my webservices, I faced some issues because of the web.config inheritance.

In the root directory I had httpHandler for 'MSCaptcha' as given below...

<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>

If you create a virtual directory, your nested ASP.NET application will not see any assembly in /bin folder or root application. That is expected behavior since /bin folder should contain only assemblies that are specific for single application. If you want to use same assembly in many applications on server, you can register it to GAC (Global Assembly Cache).

Unlike /bin folders, web.config files inherits even if nested code is separate application in virtual directory. So, if your root ASP.NET application uses some http handler you have a potential problem. Handler's assembly will be invisible for application in virtual directory, but there is still a reference to http handler in <httpHandlers > section in root web.config file. So, nested ASP.NET application will not find assembly and will return an error:

Parser Error Message: Could not load file or assembly 'AssemblyName' or one of its dependencies. The system cannot find the file specified.

To solve this issue, you can copy assembly to /bin folder of nested application and it will work, or you can register an assembly to GAC to avoid multiple copying. If you don't need that http handler use <remove > tag in <httpHandlers > section.

Happy programming!





Related Blogs