问题
I am trying to use ASP.NET precompile tool aspnet_compiler.exe to compile site after it has been deployed.
As per book definition running in-place precompile on web machine should improve first page load experience. The compilation tool compiles each ASP.NET page, storing the compiled version in the %WINDIR%\Microsoft.NET\Framework\v4.0.30319\Temporary
ASP.NET Files folder just like if the pages had each been visited for the first time from a browser. In-place precompilation can speed up the first request made to newly deployed ASP.NET pages on your site because it alleviates the runtime from needing to perform this step.
For some reason for me it does not work expected described way.
When running aspnet_compiler.exe locally on Web machine manually:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /7.1 -p C:\MyPathToWebSite\www
It created folder of following structure structure:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\7.1\640c1f87\4be3507b
When I try to hit web page using browser, ASP.NET creates another cached version in the following folder on same server:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\7.1\bc8a1bb3\42b014d4
As you can see precompile works in both scenarios (manual and IIS), but for somehow IIS does not see that pages already precompiled and cashed and trying to re-compile everything again. I could not figure out what is missing or done wrong, since aspnet_compiler.exe has limited parameter options for in-place compilation.
So far, I have tried following during testing/investigation in regards of Temporary ASP.NET cache:
- Seems like it’s not user related, does not matter what user is running manually
- Not related on Source/Target IP, since same folders are created on different servers in different subnets
Any ideas and help appreciated.
回答1:
I faced the same issue. Only using metabase path to my site solved it.
aspnet_compiler.exe -m /LM/W3SVC/[site ID]/root
回答2:
The files you see in the first folder were not jitted. You only compile your site to MSIL, and when you first access some page it gets compiled to native image code - these are the files you see in the second folder. You might want to use Ngen - http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.110).aspx
来源:https://stackoverflow.com/questions/22694822/asp-net-in-place-precompile-doesn-t-work-as-expected