A common question people often ask when hearing about the
cleaner markup coming with ASP.NET 4 is “Great - but what about my existing
applications? Will these changes/improvements break things when I
upgrade?”
To help ensure that we don’t break assumptions around markup
and styling with existing ASP.NET Web Forms applications, we’ve enabled a
configuration flag – controlRenderingCompatbilityVersion – within web.config
that let’s you decide if you want to use the new cleaner markup approach that
is the default with new ASP.NET 4 applications, or for compatibility reasons
render the same markup that previous versions of ASP.NET used:
When the controlRenderingCompatbilityVersion flag is set to
“3.5” your application and server controls will by default render output using
the same markup generation used with VS 2008 and .NET 3.5. When the
controlRenderingCompatbilityVersion flag is set to “4.0” your application and
server controls will strictly adhere to the XHTML 1.1 specification, have
cleaner client IDs, render with semantic correctness in mind, and have
extraneous inline styles removed.
This flag defaults to 4.0 for all new ASP.NET Web Forms
applications built using ASP.NET 4. Any previous application that is upgraded
using VS 2010 will have the controlRenderingCompatbilityVersion flag
automatically set to 3.5 by the upgrade wizard to ensure backwards
compatibility. You can then optionally change it (either at the
application level, or scope it within the web.config file to be on a per page
or directory level) if you move your pages to use CSS and take advantage of the
new markup rendering.