Web.Config conflict issue


Hello developers,

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/

Configuration Error

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=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ has already been added.

Source Error:

Line 30: <pages validateRequest=”false”>

Line 31: <controls>

Line 32: <add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>

Line 33: <add tagPrefix=”ajaxToolkit” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=3.5.0.0, 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=3.5.0.0, 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.

Reason-

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

Swagat


Advertisements

9 thoughts on “Web.Config conflict issue

    • Hey,

      Thanks for reading this article and your comment. I understood where you are pointing at. But, let me explain few things so that it would answer your point.

      The below error
      Line 71:

      has appeared as because parent config was looking for an assembly of Lanapp.BotDetectt in the child bin folder. This particular verb tag was in the parent config. So each of the applications under the parent has to have the assembly inside their bin. I can’t remove or comment out this tag in parent as the assembly been used in the application.

      I hope this answers your point. Please let me know if you have any further feedback.

      Thanks and Best Regards
      Swagat

      • Quote: “I can’t remove or comment out this tag in parent as the assembly been used in the application.”

        Don’t remove it from parent application’s web.config. Remove it in each of child applications’ web.config-s since it is not used in them.

        I.E:

        <add verb=”*” path=”LanappCaptcha.aspx” etc…
        => goes into WAP-A.com/web.config

        <remove verb=”*” etc…
        goes into WAP-A.com/WAP-B/web.config
        goes into WAP-A.com/WAP-C/web.config
        goes into WAP-A.com/WAP-D/web.config
        etc…

  1. Lanapsoft Support :

    Quote: “I can’t remove or comment out this tag in parent as the assembly been used in the application.”

    Don’t remove it from parent application’s web.config. Remove it in each of child applications’ web.config-s since it is not used in them.

    I.E:

    <add verb=”*” path=”LanappCaptcha.aspx” etc…
    => goes into WAP-A.com/web.config

    <remove verb=”*” etc…
    goes into WAP-A.com/WAP-B/web.config
    goes into WAP-A.com/WAP-C/web.config
    goes into WAP-A.com/WAP-D/web.config
    etc…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s