views:

585

answers:

2

I've currently got a ASP.NET MVC 2 application on .NET 3.5 and I want to migrate it over to the new .NET 4.0 with Visual Studio 2010.

Reason being that it's always good to stay on top of these things - plus I really like the new automatic encoding with <%: %> and clean web.config :-)

So, does anyone have any experience they could share? Looking for gotchas and the likes.

I guess this could also apply to any ASP.NET Forms projects aswell.

TIA,
Charles

+1  A: 

I just went through that process. It was relatively painless. It'll give you a chance to do some house cleaning with your web.config files, as you mentioned.

There's one area I had trouble with. If you're taking advantage of the post build ASP.NET compile task in the project file via MvcBuildViews = true, you may experience a problem if you then attempt a publish. Apparently VS 2010 stages files within your project's subdirectory, resulting in the ASP.NET compiler detecting multiple web.config files. There's a full explanation and a response by Microsoft on this post:

http://forums.asp.net/p/1547458/3797505.aspx

Otherwise the process was pretty smooth.

SevenCentral
Awesome, I actually came across that problem with `MvcBuildViews=true` and VS2010's publish before. Thanks for the link :-)
Charlino
Hmmm, what steps did you take? I upgraded my VS Project to .NET 4 - which clean up my web.config for me. I then updated my app-pool in IIS7.5 to use the .NET 4 framework but now the site is throwing a 500.19 - Cannot read configuration file due to insufficient permissions. But the app-pool identity definately has rights to read the file, and the IIS anonymous authentication is definately using the app-pool identity. Any ideas?
Charlino
Don't worry about that last comment - it seems that when I upgraded the project to .NET 4 it changed my app-pool for the website automatically to the new ASP.NET v4.0 app-pool. I just had to change it back.
Charlino
+1  A: 

Gotcha #1 - Changes application pool

If your ASP.NET project is setup to use IIS and not Cassini, during the upgrade to .NET 4.0 process it'll automatically change the application pool that your site uses to the new ASP.NET v4.0 application pool. This may have an effect on permissions if you are using the application pool identity for anonymous authentication.

Gotcha #2 - [ValidateInput(false)] stops working

This is a breaking change in ASP.NET 4.0. A related question can be found here.

The jist is that you must add <httpRuntime requestValidationMode="2.0" /> into your web.config.

Charlino