发布于 2016-06-08 06:23:33 | 155 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

.NET Framework

.NET 是 Microsoft XML Web services 平台。你可以理解为.NET Framework ,XML Web services 允许应用程序通过 Internet 进行通讯和共享数据,而不管所采用的是哪种操作系统、设备或编程语言。Microsoft .NET 平台提供创建 XML Web services 并将这些服务集成在一起之所需。对个人用户的好处是无缝的、吸引人的体验。


这篇文章介绍了.net输出重写压缩页面文件的小例子,有需要的朋友可以参考一下

不知你是否留意过,有一些网站的html代码都是混在一起,没有任何空格和换行等多余字符。它的好处不用多说——界面大小绝对优化。或许您在想,他们这样做大大降低了可读性。的确,我们看是很乱,只能借用第三方软件重新布局代码。但是,我想他们开发时使用的源码不可能是混一团,前不久发现一个页面基类,大概可以解释这个问题,不多说,看源码:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.htmlControls;
using System.Text.RegularExpressions;
using System.IO;

/// <summary>
/// PageBase 页面基类
/// </summary>
public class PageBase : System.Web.UI.Page
{
    protected override void Render(htmlTextWriter writer)
    {
        StringWriter sw = new StringWriter();
        HtmlTextWriter htmlWriter = new htmlTextWriter(sw);
        base.Render(htmlWriter);
        string html = sw.ToString();
        html = Regex.Replace(html, “[f v]“, “”);
        html = Regex.Replace(html, ” {2,}”, ” “);
        html = Regex.Replace(html, “>[ ]{1}”, “>”);
        writer.Write(html);
    }
}



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务