Codepolice

Random posts from Ola in English. Mainly about programming and the web.

Upgrade an ASP.NET Webforms application from 3.5 to 4.0

Today i decided to upgrade our site AlternativeTo to ASP.NET Framework 4.0 and naturally there where some stuff that didn’t work. Hopefully someone else who is having the same issues will find this post and get some help from it.

I started by follow this article from MSDN about upgrading from 3.5 (or lower) to 4.0. I followed the manual upgrade process in the article since my site is kind of custom and also because i need to do the same changes in my production enviroment and wanted to know what is happening under the hood.

I should point out that i am running my code in IIS and not in the built in web server to mimic the production environment as close as possible.

  • My first issue was that according to the guide on MSDN i should delete everything in the system.webserver section of my Web.Config. Previously in the article they had pointed out that if i had added any custom stuff anywhere i should keep that. Since i had a lot if custom stuff in my system.webserver section i did not do as the guide suggested here. I guess i should do a trial and error and remove stuff that i think is safe to remove. The reason why you should delete a lot of stuff in the Web.Config is explained by Scott Guthrie in his web.config blog post.
  • After i followed the guide i tried to start my site and got the error “Unrecognized attribute ‘targetFramework’“. I got this error because i had to change the target framework on the App Pool. Just right click the app pool and choose “advanced settings” and you find this setting at the top. But i still got a “anonymous” 500 error after this.
  • Then i tried to create a new site target with .net framework 4.0 and i got a slightly better error 500.19 that was actually “Googleable” and i found out that it was some kind of security issue. I moved my site to a folder outside my “my documents” space and .. another error! yey!
  • I got the error ‘“PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list‘. This was also kind of easy to find and the post from Got Know How suggested me to reinstall .net framework 4.0 and finally everything worked!

It was actually kind of an easy upgrade. I should point out that i haven’t tested the site that much yet and it’s not installed in my production environment but it should probably not be that big of a deal.

Leave a Reply