Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET recompiles on every request

Tags:

c#

asp.net

iis-8

I have a ASP.NET Webforms compiled site that works flawlessly on my local machine. As soon as the site is pushed up to the live servers (A bank of 10 servers running IIS8 on windows server 2012) the site will recompile on every request.

If I go to the temporary ASP.NET files directory there are App_Web dlls for all the user controls in the site along with .delete files for all the binaries which is what I think is causing the appdomain to restart every time.

App_Web_course.aspx.cdcab7d2.ijbbuqi7.dll
App_Web_course.aspx.cdcab7d2.ijbbuqi7.dll.delete

It does occasionally run OK on some of servers and when I look at the temp .NET files on those servers the .delete files aren't there.

I'm pulling my hair out, In 17 years of development, I've never seen this before and there seems to be no rhyme or reason for it.

Update: If anyone else experiences this, please check my answer below for my resolution.

like image 205
David Rabbich Avatar asked May 10 '16 09:05

David Rabbich


2 Answers

I have an update and solution to the problem.

At the time of the original post, I had left out that the files were located on an SMB network share. This has been the cause of this constant recompiling due to the fcnMode of ASP.NET.

Process Monitor showed thousands of requests through w3wp.exe for "FileChangeNotify" which when hitting a critical directory such as "bin" it would cause a recompilation and application restart.

Luckily there is a single line fix for this. In the web.config(s) of your project, alter the following line to include the following attribute:

<httpRuntime fcnMode="Disabled" />

This will stop ASP.NET from scanning your network directory for constant file changes.

like image 87
David Rabbich Avatar answered Nov 17 '22 12:11

David Rabbich


Possible reasons that cause recompile.

  • You update the web.config
  • You create/delete the app_offline.htm file on the root.
  • You create/modify any .aspx or .aspx.cs file
  • You create/modify files on App_Code folder
  • You have left some upload folder unattended and users upload aspx files.
  • You time/date on the computer is wrong (back some years)

You can use the Process Monitor to see what happening from all that if you can not locate it on code or don't know what other libraries do.

like image 33
Aristos Avatar answered Nov 17 '22 11:11

Aristos