Web.Config Issues Deploying .NET 4.0 MVC2 Site To IIS7

In .NET 4.0 they cleaned up a lot of the configuration elements for a web site’s web.config and moved it the the frameworks machine.config.  This has greatly streamlined the web.config.  The other day I was deploying a MVC2 site running under .NET 4.0 to an IIS7 web server and received a configuration error stating “There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined”.  It turns out that MVC2 project template comes with come web.config settings which work under .NET 2/3.5, but are redundant in 4.0.  In order to fix this, remove the following settings, the type attributes have been removed for brevity.

<sectionGroup name="system.web.extensions" ...>
<sectionGroup name="scripting" ...>
<section name="scriptResourceHandler" .../>
<sectionGroup name="webServices" ...>
<section name="jsonSerialization" .../>
<section name="profileService" .../>
<section name="authenticationService" .../>
<section name="roleService" .../>

See ASP.NET 4 Breaking Changes for details on breaking changes in .NET 4.0.

No comments: