In this article i am going to describe an interesting topic regarding ASP.NET web application hosting issue due to Web.Config configuration.
I want to give an live example which would make this issue more easier to understand…
When I was working in a Web Application(WAP A), it has 3 sub Web Applications(WAP B, WAP C, WAP D). All applications were havng their own solution and project file. While development there were no config issues as I directly compile the code and run.
But the moment I pushed one of the Web Application(WAP C) into the server after creating its virtual directory then I met an issue called Web.Config conflict issue. The WAP C application was throwing errors on Config file. You must be wondering with this. you might think also that I could have done some wrong Virtual directory settings. Ok you would get your all answers below.
OUR SITE AND VIRTUAL DIRECTORY STRUCTURE ON SERVER
The setups were like below
-> Root( Web Site – WAP-A.com)
-> Virtual Directory( WAP-A.com/WAP-B/)
-> Virtual Directory( WAP-A.com/WAP-C/
-> Virtual Directory( WAP-A.com/WAP-D/)
And the Directory structure were like below
WAP A was inside D:/WAP A/ directory.
And all others were inside D:/WAP A/ like D:/WAP A/WAP B/.
When I completed the virtual directory setup for WAP B then I got the below error while running http://WAP-A.com/WAP-B/
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: The entry ‘asp:System.Web.UI:System.Web.Extensions, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ has already been added.
Line 30: <pages validateRequest=”false”>
Line 31: <controls>
Line 32: <add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
Line 33: <add tagPrefix=”ajaxToolkit” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
Line 34: <add tagPrefix=”ajaxToolkit” namespace=”AjaxControlToolkit” assembly=”AjaxControlToolkit”/>
And when I tried commenting the above tags in WAP B config file then it threw an issue in the below line
Line 80: <add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
Again I commented the above line in WAP B config file, then it threw another error as below
Line 71: <add verb=”*” path=”LanappCaptchaa.aspx” type=”Lanapp.BotDetectt.CaptchaaHandler, Lanapp.BotDetectt”/>
Above was the assembly info for a 3rd party DLL. It could be any thing.
Then I included the particular DLL into the WAP B bin folder and the site worked fine.
Just think why all these issue happened while hosting, and I never faced this on development phase.
When we host any virtual directory under the site which has the Config file with same tags, then the Virtual Directory site considers the tags as duplicate tags in its Web.Config file. The Parent chile relationship would be generated in such cases. So the Child site would inherit the properties or tags in Web.Config file from the main or root site. This is the reason why the 3rd party DLL assembly info issue came up. Because the child site got the info from parent config file that it needs the assembly configuration in the solution. So after placing the proper DLL the issue got resolved.
Hope the above explanation helps you all in understanding this issue. Also make sure that you create the same environment on your development phase before publishing into production. it helps us to avoid such kind of unknown issues.
Thanks for reading this article.
With Personal Regards