首页 / 网页编程 / ASP.NET / 使用aspnet_compiler.exe预编译网站
使用aspnet_compiler.exe预编译网站2011-07-19 csdn博客 fer_ba第一步:切换到aspnet_compiler.exe所在目录在“命令提示符”下,切换到所在目录“c:windowsmicrosoftframeworkv2.0.50727”。第二步:运行aspnet_compiler.exe预编译Aspnet_Compiler -v test c: mp est-v是虚拟目录参数,test为虚拟目录名称,而c: mp est是指先行编译后的程序文件的目的位置。第三步:使用预编译后的网站将预编译后的test目录Copy到正式网页服务器,部署网站。但要注意:aspnet_compiler.exe不会对静态文件如:Web.config、文本文件和图片文件等进行编译,所以像数据库连接字符串请用 aspnet_regiis.exe工具来进行加密。网站预编译后,以后也不会触发重新动态编译,故请不要事后再加入新的.aspx文件,那样不会有任何作用。也可通过ClientBuildManager类进行编译string vdir = "/MyDataSource"; //虚拟目录名称string srcLocation = "c:\Inetpub\wwwroot\VS2005IDE"; //来源位置string tarLocation = "c:\tmp\VS2005IDE"; //目标位置System.Web.Compilation.ClientBuildManager cbm = new System.Web.Compilation.ClientBuildManager (vdir,srcLocation,tarLocation);cbm.PrecompileApplication(); //预编译