Scott Hanselman

ASP.NET 4 - Breaking Changes and Stuff to be Aware of

April 12, 2010 Comment on this post [6] Posted in ASP.NET | VS2010
Sponsored By

If you're getting started with ASP.NET 4, there's a few things you might run into that could throw you for a loop if you didn't expect them. Remember that while ASP.NET is a very compatible release, it is also a side-by side release so this was a good time to make breaking changes for the better.

Note that just installing ASP.NET 4 won't break your applications. You can happily run all your ASP.NET applications side by side each in their own AppPool. These first two "gotchas" below are if you're moving an existing application over to .NET 4. The third gotcha is an install ordering thing.

Request Validation is more strict by default.

Request validation is more strict by default in ASP.NET 4.  Pretty much anyone moving a non-trivial ASP.NET 2 application over to ASP.NET 4 has a good likelihood of running into this.  The workaround is pretty simple. If you want to revert the behavior of the validator to pre-ASP.NET 4, add this to your web.config:

<httpRuntime requestValidationMode="2.0" />

That's it. Of course, you can always dig in a bit and see why your app doesn't like the stricter validation and fix that as well.

"I switched my ASP.NET 2/3.5 application over to an ASP.NET 4 application pool and it broke because I didn’t run the VS2010 upgrade wizard"

If you just go into IIS and change your existing app's AppPool to ASP.NET 4, you might get an error. The nitty gritty details are here, but the average customer's brain will melt reading the details.

So instead, a quick way to fix this (assuming you don't want to upgrade the app) is

  1. Make sure you have SP2 installed if they are running Vista and Windows Server 2008. If you are in Windows7 then no service pack is needed.
  2. Go to your application's web.config and wack the standard <configSections> definition at the top.
  3. Although not required, toss the <system.codedom> section towards the middle of the web.config since it isn’t needed either.

That's it.

"I installed ASP.NET 4 and then installed IIS."

If you install VS2010 and/or .NET 4 first, then later install IIS, you need make sure IIS is configured to know about ASP.NET 4 otherwise IIS will have no idea how to run ASP.NET 4 applications.

There's a simple workaround:

  • If you are already in this state, drop to the command line and navigate to the FX install directory.  Then run "aspnet_regiis –iru". 
    • Note if you are on a 64-bit machine, run this command from the 64-bit FX install directory – not the 32-bit installation directory.

or for future reference, try to enable IIS and the ASP.NET extensibility option *first* when your are building machines or VMs.  That way when VS 2010 or .NET are subsequently installed, the installation will automatically detect the presence of IIS and will auto-register with it.

Hope this helps. The complete list of ASP.NET 4 Breaking Changes is here.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service
April 13, 2010 4:26
Speaking of ASP.NET and breaking, it might be worth a mention that if you have a VS2008 MVC & test project, then upgrade it to VS2010 the upgrade wizard will prompt to upgrade to .Net 4.0, if you choose no the test project still gets upgraded to .Net 4.0 and the project properties will not let you change it back to .Net 3.5 – one to watch out for, but not the end of the world.
April 13, 2010 4:35
One other gotcha: The RTM version of VS2010 and the Silverlight Tools for VS2010 RC don't play well together (i.e., doesn't work at all). Since SL4 is supposed to be released this week, probably not a huge deal. But if you are doing active dev on SL4, might want to stick with VS2010RC and hold off on the upgrade to the VS2010 RTM until SL4 is official.
April 13, 2010 22:26
I didn't get VS2010 yet but I'll tomorrow and first thing to check is new deployment stuff.
Project deployment (with database ) on commercial hosting must be more approachable and I expect that with asp.net 4.0 .
April 30, 2010 12:23
Does the ASP.NET is really very compatible & release a side-by side release so this was a good time to make breaking changes for the better ??
August 23, 2010 15:06
Does the ASP.NET is really very compatible & release a side-by side release so this was a good time to make breaking changes for the better ??
December 14, 2010 1:17
Thank you so much! I've been looking all over the internet to find a solution as to why I couldn't get my mvc application to work and here was the answer. Again, thank you!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.