ASP.NET 4 - Breaking Changes and Stuff to be Aware of
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
- 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.
- Go to your application's web.config and wack the standard <configSections> definition at the top.
- 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.
About Newsletter
Project deployment (with database ) on commercial hosting must be more approachable and I expect that with asp.net 4.0 .
Comments are closed.