You may run into “The file has not been pre-compiled, and cannot be requested” error intermittently while accessing your ASP.NET application. The intermittent nature of the issue makes it hard to troubleshoot but there are a couple of common causes of this issue. Let’s have a look a them and the possible solutions.
The error message
Here is the full error message from Event Viewer (Event ID is 1309):
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 8/13/2019 5:30:37 PM
Event time (UTC): 8/13/2019 9:30:37 PM
Event ID: fb6cbd06310e4e1691aea324e43874ae
Event sequence: 5
Event occurrence: 3
Event detail code: 0
Application domain: /LM/W3SVC/1/ROOT/ApplicationX-1-132102041647233704
Trust level: Full
Application Virtual Path: /ApplicationX
Application Path: E:\inetpub\wwwroot\ApplicationX \
Machine name: ServerX
Process ID: 2276
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception type: HttpException
Exception message: The file ‘/ApplicationX/Login.aspx’ has not been pre-compiled, and cannot be requested.
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
Root cause and solution for “The file has not been pre-compiled, and cannot be requested” error
This issue occurs because the application is not able to load one or more libraries it needs. Most of the time, an assembly that web.config references is not available in the application directory or GAC.
Here are the most common causes of the issue:
- There is a known bug in .NET Framework 4.7.x that causes this issue. There is a public post here in regards to this bug
- Web.config file references an assembly but this assembly doesn’t exist in the application folder or GAC
- There is an assembly file in the application folder but it is not referenced by the web.config file
For the 2nd and 3rd causes, I would recommend turning on Assembly Binding Logging to see which assembly is causing this issue: How to enable Assembly Binding Logging (Fusion Log Viewer – fuslogvw.exe)?
- Incorrect version of the assemblies are being used
- It’s a 32-bit application and “Enable 32-bit applications” is set to false
- Temporary ASP.NET files are causing the issue (
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root)
- There are extra files in the publish location. “Remove additional files at destination” is not selected in the Visual Studio Publish Profile
- If there is a script used for deployment, it may not be clearing the target folder properly or it may not be copying all the files from the source
- There is not enough disk space in IIS
I won’t be able to provide solution for each of these causes but I am hoping that knowing these possible causes will help narrowing the issue down.
Here are a helpful StackOverflow post, an ASP.NET forum topic, and a MSDN blog post about this issue.
If you find yourself troubleshooting an assembly related issue, this post may help: How to find out the Public Key Token for an assembly (DLL) file?
1 thought on “The file has not been pre-compiled, and cannot be requested (Solved)”
I disagree with Step 4 in this article…
For us, just removing the files under “C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root” did NOT work.
Instead, we had to delete ALL of the files and folders under:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
Only then did the error go away.