Migrating ASP.NET (MVC 2) on .NET 3.5 over to .NET

2020-07-23 08:47发布

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

2条回答
神经病院院长
2楼-- · 2020-07-23 09:16

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.

查看更多
时光不老,我们不散
3楼-- · 2020-07-23 09:23

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.

查看更多
登录 后发表回答