How to fix ASP.NET error “The file 'nnn.aspx' has not been pre-compiled, and cannot be requested.”?

后端 未结 25 3112
时光说笑
时光说笑 2020-12-05 22:35

I have a VS 2005 web site that I publish using \"Publish Web Site\", and I clear all the three checkboxes. I also have a deployment project that picks up the published files

25条回答
  •  醉话见心
    2020-12-05 23:00

    I have been struggling to fix this issue for past few days. At least in my case, the error message was completely misleading and had nothing to do with precompiled website. There are many articles or posts out there that give many different answers which only add to confusion. I personally believe this error is caused mainly due to missing references or incorrect versioning. In order to fix the issue as fast as possible you have to rule this out, or otherwise fix the missing/wrong reference.

    To do so you need to use a tool named "Assembly Binding Log Viewer". This tool will tell you which references are missing or have wrong versions. If there is a missing/mismatched reference then go ahead and fix it; otherwise you need to do the other magic tricks like checking for App Pool being 32-bit or permissions.

    Steps:

    1. At your server create the following folders

      C:\fuslog C:\fuslog\logs

    2. Copy Assembly Binding Log Viewer to your server at C:\fuslog:

      You can find the program at a location like this

      C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\fuslogvw.exe

      You might need to look at "Program Files" instead of "Program Files (x86)" or look into different vesions instead of "v7.0A"

    3. Execute fuslogvw.exe at server

    4. Click on "Setting..."

    5. Ensure "Log bind failures to disk" is checked

    6. Check the Enable custom log path and enter the following in the box: C:\fuslog\logs

    7. Click on OK

    8. Recycle/reset your app pool to enforce a fresh binding

    9. Click on Refresh. Now you can see the failed binding in here

    10. The better way to find the exact binding is to go to c:\fuslog\logs\Default. In here you can find the exact binding failures. Some are irrelevant and you need to find the critical one by trial and error. Mine was the following failure:

       System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35
      

    I fixed the issue by adding the following entry at my web sites web.config:

    
        ...
        
            ...
            
            
                
                
            
            ...
        
        ...
    
    

    I hope this helps others to quickly fix the issue.

提交回复
热议问题