There is a duplicate scriptResourceHandler section defined

In this blog, I am going to point out one common error which we usually get after deploying an ASP.NET 3.5 website on the IIS Server, however we do not see this error during development i.e. in Visual Studio. Actually this issue only happens when the application pool is using .net framework 4.0 in IIS, but we will try to understand why?

Here is the screen shot which we see when this problem occurs.


As we can see the message is pretty much clear “There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined”, pointing out a duplicate entry in the application web.config file at this path “E:\New\TestWeb\TestWeb\web.config”. So we can easily get rid of this issue by removing the entry from the application’s web.config file.

But the question is how do we get this entry in the web.config file? and How does this work in the Visual Studio? Let’s investigate this.

Following is that same section of web.config file opened in Visual Studio from the same solution, we can see that “scriptResourceHandler” section is present there. So we simply use the Visual Studio publish feature to deploy this application content on the IIS server and the content along with web.config file simply gets x-copied on the target location during this. Following is the screen shot of one such web.config file.


Let’ see what this ScriptResourceHandler is.

ScriptResourceHandler class was introduced in .net framework 3.5. This is actually a HTTP handler for processing requests for script files that are embedded as resources in an assembly. Read here for more on ScriptResourceHandler.


Apparently, you can also find a handler entry in the httpHandlers section of the same application web.config file.


We know that ASP.NET framework 3.5 uses the CLR version 2.0 and that is why framework 3.5 does not have any root web.config file like version 2.0 or 4.0 have at this location


Since CLR version is same, framework 3.5 specific section tag definitions is not present in the machine.config file respective to the version 2.0. While creating the 3.5 framework website, Visual Studio does this job for us. Visual Studio adds these section tag inside <configSections> and a respective “handler” entry in the web.config file.

So after deploying the application on IIS server, if we choose .Net framework 2.0 for the application pool, it works fine without deleting any entry from the web.config because settings required for framework 3.5 website to run are added in application web.config file and they do not exist in Machine.config file for framework 2.0.


Now what if we are bound to use .Net Framework 4.0 (Note: If you are creating a version 4.0 website in Visual Studio from the scratch, then Visual Studio will not add the specified entries in web.config file and this issue will never happen.). This situation may occur if we are upgrading our website from 3.5 to 4.0 framework.

Let’s open the machine.config file from this path %windir%\System32\Microsoft.NET\Framework64\ v4.0.30319\Config\machine.config and search for “scriptResourceHandler”. We can see that this entry is already there, so that is why, having this entry again in application web.config results into this error.


Let’s also search the root web.config file from this path %windir%\System32\Microsoft.NET\Framework64\ v4.0.30319\Config\web.config and search for  “scriptResourceHandler”. We can see that handler entry is already there. (Which was added in web.config however, existence of handler entry does not make any difference here since handlers can be specified at any level of web.config files hierarchy overriding the configuration of parent web.config)


So since we already have the entries in machine.config file of .net framework 4.0, again adding same entry in the application specific web.config file results into this error.


If you want to cross check this, follow these steps.

1. Open Visual Studio 2010

2. Create a new website of of framework 4.0.

3. Open the web.config file and check for above mentioned entries. You will not find any of the those entries, here is the screen shot.


4. Now change the framework of the website from 4.0 to 3.5 from website Property pages.


5. Now open the web.config file and check for its content. You will see all those entries in the file and you will get to know that how much Visual Studio takes care of developers.




Hope this was helpful, please feel free to write the feedback.