首页 > 代码库 > ASP.NET-Web项目运行缓慢-AjaxMin在搞鬼

ASP.NET-Web项目运行缓慢-AjaxMin在搞鬼

AjaxMin 4.8版本是没问题,出现问题的时候是AjaxMin 5.3.xxxxx版本,起初我也不知道是AjaxMin出现问题一直以为是因为我大幅度修改Web项目架构,以及采用大量反射后所带来的后遗症。

 

记得当时是这样的,我不满足现有Web项目的运行速度,想要让它更快一些,而且现有的Web项目架构一团糟,不便于日后的扩展和维护,于是乎,我向领导申请一定的时间用于Web项目架构的修改。

批下来之后,我开始动手修改Web项目架构,从DbHelper动手,按照兼容的原则,添加了大量的反射方法,用于封装实体类,以及填充泛型集合IList,这是Persistence持久层优化部分。

至于Web表现层,采用了Combres+dotless+YUICompressor.NET+AjaxMin,用于css代码合并压缩+js代码合并压缩,减少css文件大小和js文件大小,以及减少http的多次请求。

整个Web项目处理完后,运行起来发现,访问速度龟慢...一直以为是我自己写的代码有问题,百般调试无果。

<script type="text/javascript">// </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script><iframe style="display: none;" id="google_esf" vspace="0" height="0" marginHeight="0" src="http://googleads.g.doubleclick.net/pagead/html/r20140501/r20140417/zrt_lookup.html" frameBorder="0" width="0" allowTransparency="true" name="google_esf" marginWidth="0" scrolling="no" hspace="0"></iframe><script src="http://pagead2.googlesyndication.com/pagead/js/r20140501/r20140417/show_ads_impl.js"></script><iframe id="google_ads_frame1" vspace="0" height="15" marginHeight="0" src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-9251186853795166&output=html&h=15&slotname=8060262136&adk=2915868498&w=728&lmt=1399627278&flash=0&url=http%3A%2F%2Fwww.cnblogs.com%2FVAllen%2Fp%2FAjaxMin-Running-Slow-Solutions.html&dt=1399627279227&shv=r20140501&cbv=r20140417&saldr=sb&correlator=1399627279271&frm=20&ga_vid=429972749.1397695120&ga_sid=1399623329&ga_hid=2037792342&ga_fc=1&u_tz=480&u_his=108&u_java=1&u_h=768&u_w=1364&u_ah=740&u_aw=1364&u_cd=16&u_nplug=0&u_nmime=0&dff=%E5%BE%AE%E8%BD%AF%E9%9B%85%E9%BB%91&dfs=15&adx=421&ady=596&biw=314&bih=74&eid=317150304&oid=3&rx=0&eae=0&docm=9&vis=0&fu=0&ifi=1&xpc=3y19mbcYfP&p=http%3A//www.cnblogs.com&dtd=69" frameBorder="0" width="728" allowTransparency="true" name="google_ads_frame1" marginWidth="0" scrolling="no" hspace="0"></iframe>

打开Visual Studio分析—性能和诊断界面,对Web项目进行分析,运行分析后,发现一个叫Microsoft.Ajax.Utilities的命名空间内的某类,运行速度最慢,而Microsoft.Ajax.Utilities是AjaxMin.dll内的。

我当时没想过升级AjaxMin版本,一直很纠结,直到某次用Nuget升级其它dll文件,顺带升级AjaxMin至5.9版本,突然发现,速度快了好多,太棒了。

至此,这个文章就写到这里,作个案例,提供给使用AjaxMin的伙伴们做个参考吧。