小弟最近在淘宝看到有类似下面一段代码
<link href="http://a.tbcdn.cn/p/fp/2011a/??html5-reset-min.css,global-min.css,header/header-min.css,product-list/product-list-min.css,attraction/attraction-min.css,expressway/expressway-min.css,category/category-min.css,category/sub-promotion-min.css,guide/guide-min.css,hotsale/hotsale-min.css,bottom-gg/bottom-gg-min.css,subfooter/subfooter-min.css,footer/footer-min.css?t=20110513.css" rel="stylesheet" />好像是通过一个请求在服务器合并了所有的样式表文件,减少了http请求,但是我不会C#,请问
怎么用C#实现这种方法?能不能给个例子参考一下?多谢各位~~

解决方案 »

  1.   

    不一样的嘛?!
    链接里面指定了样式文件名,指定了目标样式名,把样式文件的路径配置在web.config中,剩下的,就是读写文件的操作了。
      

  2.   

    参考
    http://dancewithnet.com/2010/06/08/minify-js-and-css-files-in-server/
    如果代码没有交叉歧义,后台简单合并也是可以的
      

  3.   


    这个帖之前已经看过了,但是不是很明白其中的过程,后台是怎么读取到前台<link>里面的值呢?
    <link>是不是会提交这个请求?
      

  4.   


    被封装了,当然看不到过程。
    我想的有点简单了,前面没看清楚命题,感觉合并js和css不是难点,难点在于对于<link>标签中href的解析。
    既然写成这样,必然是在HTTP请求载入样式时,有一个拦截,在拦截中写解析规则,c#能不能做到,我也表示怀疑,期望牛人解决。
    "<link href="http://a.tbcdn.cn/p/fp/2011a/??html5-reset-min.css,global-min.css,header/header-min.css,product-list/product-list-min.css,attraction/attraction-min.css,expressway/expressway-min.css,category/category-min.css,category/sub-promotion-min.css,guide/guide-min.css,hotsale/hotsale-min.css,bottom-gg/bottom-gg-min.css,subfooter/subfooter-min.css,footer/footer-min.css?t=20110513.css" rel="stylesheet" />"