ASP.NET WebForm 2.0 work in Windows Server 2012 R2 again

There is a medium web application in the company that is in use since 2006 to now (2016). This web application is developed with ASP.NET Webform and .Net 2.0 in days of AjaxControlToolkit. For those unfamiliar with that, AjaxControlToolkit and UpdatePanel was an easy way for ASP.NET developers to make use Ajax, the hot technology of the day, in their web applications. Our company web application is hosted in a MS Windows 2003 and now must be hosted to a recent Windows version happened to be MS Windows 2012 R2. This story is about how we manage the application work again in new environment.

The application files copied to a folder in inetpub\wwwroot then an application created for it in IIS. Application was not working with .Net 2.0 App pool because of error “HTTP Error 404.17 – Not Found”. We decided to make it work with a .Net 4.0 App pool. The first error dumped was easy to handle. ASP.Net 4 has some entries of old web.config files into itself so was throwing error duplicate entries. This problem solved by removing those entries from web.config. After it the application get up correctly.

After some usage of the application we explored that some internal tabs are not opening after clicking. Guessing started here. The first guess was that IIS is not serving some file like a .js or a .css file correctly. It was no true because IIS logs and browser profilers did not record any relevant 404 error. Second guess was that something is wrong with AjaxControlToolkit. Our guess was that panels are changed with help of AjaxControlToolkit and UpdatePanel. I checked with Chrome's developer tool. No related console error existed. In another try I changed versions of System.Web.Extensions and AjaxControlToolkit to 3.5.0.0 but didn't helped. Next time added assemblyBinding to web.config but this does not helped too. Event logs of Windows showed no suspicious item too. Several searches in Google neither helped too.

Being hopeless decided to debug client side code of the application in the Chrome developer tool despite of its 4.5K lines of code of legacy ASP.NET WebForm 2.0 application. Started my work by examining JavaScript function that was called by tab headers. javascript:__ShowTAB('ctl00_ContentPlaceHolder1_Panel3',3) was one of those functions. Tracing function calls showed that in an “if comparison” client Ids are not equal. I found it! Client Id generating was changed from .Net 2.0 to .Net 4.0. New one was shorter and didn't had prefix “ctl00_” in beginning of it. A StackOverflow question had same problem. A 2010 post of Scott Gu was showing the complete cause of the problem. ASP.NET 4 WebForm has been moved along a way to generate a cleaner client id. This behavior could be controlled via ClientIDMode. Unfortunately default value of this property was not AutoID while ASP.NET 2.0 behavior was as same as AutoID. I added ClientIDMode = AutoID to the directive of the master page and the problem solved peacefully.

One thought on “ASP.NET WebForm 2.0 work in Windows Server 2012 R2 again”

Leave a Reply

Your email address will not be published. Required fields are marked *