I've got a web app solution containing a class library project.
When开发者_如何学Goever I rebuild the class library and then refresh the page, it takes ages the first time, and is then quick again subsequently.
It's almost as if the newly rebuilt dll is having to 'bed in' to the app.
Can anyone tell me what's really going on behind the scenes?
Thanks
David
It's almost as if the newly rebuilt dll is having to 'bed in' to the app.
That's exactly it. The first time ASP.NET actually loads up an assembly is when it gets JITted. You can move this startup time from the first time the application is used to the time it gets built by including something along these lines as a post-build event in the project:
aspnet_compiler.exe -p $(ProjectDir) -v /
Check the docs for aspnet_compiler
for background info and more options.
If you're talking about Web Site (not Web Application) ASP.NET needs to recompile all the assemblies behind the scene. And this requires restarting the app domain.
Because the asp.net website is compiling the website the first time it runs, you can precompile the website to avoid this behavior.
Or you can make a website project
精彩评论