ScriptResource does not recognize enableCompression

1

I am migrating Asp.net 2.0 web application from Windows Server 2003 to Windows Server 2012. I am getting following error in Windows Server 2012.

“HTTP Error 500.19 - Internal Server Error”.

Config Error: Unrecognized attribute 'enableCompression'

Error Code: 0x8007000d

Problem is in the following configuration element.

<add name="ScriptResource" enableCompression="false" preCondition="integratedMode"  
verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, &#xA; 
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, &#xA;      PublicKeyToken=31bf3856ad364e35"/>

When I remove the attribute enableCompression="false" the error is gone and even the ajax functionalities are working fine. Why is the attribute throwing error in Windows Server 2012 and what can we do to make it working in Windows Server 2012?

Application Pool setting is listed below.

enter image description here

asp.net
ajax
asked on Stack Overflow Oct 2, 2015 by Lijo

1 Answer

2

Indeed, in looking at the official IIS documentation, it appears that the "enable compression" attribute does not exist for the "add" element of the handlers collection:

https://www.iis.net/configreference/system.webserver/handlers/add

This would explain the error, and why removing the "enable compression" attribute results in no further issues.

The truth is that you do not need this attribute any longer. If your application is working without it, then you are good to go. All this tag would do in ASP 2.0 is compress the javascript for a small performance gain in transferring the script to the client. If your javascript filesize is minimal, then this is a very negligible gain.

More importantly, notice that your original code calls enable compression = false. That means the original code had explicitly disabled compression for some reason. The default modern behavior would disable compression as well. Therefore, your new code is behaving the same without the attribute as the original did, with respect to compression.

Finally, the modern method of enabling compression / caching for javascript embedded as assembly resources is to utilize the scriptResourceHandler Element.

Example:

<scriptResourceHandler 
enableCompression="true|false" 
enableCaching="true|false" />

See the MSDN documentation here: https://msdn.microsoft.com/en-us/library/vstudio/bb513840(v=vs.100).aspx

answered on Stack Overflow Oct 6, 2015 by HBomb • edited Oct 6, 2015 by HBomb

User contributions licensed under CC BY-SA 3.0