﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-2008,我的新起点</title><link>http://www.cnblogs.com/kwongwah/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 07 Sep 2008 22:36:57 GMT</lastBuildDate><pubDate>Sun, 07 Sep 2008 22:36:57 GMT</pubDate><ttl>60</ttl><item><title>截取中英文混合字符串</title><link>http://www.cnblogs.com/kwongwah/archive/2008/05/23/1205995.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Fri, 23 May 2008 11:43:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/05/23/1205995.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1205995.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/05/23/1205995.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1205995.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1205995.html</trackback:ping><description><![CDATA[/// &lt;summary&gt;<br />
&nbsp;&nbsp;&nbsp; /// 截取中英文混合字符串(中文字符一个按两个字符算)<br />
&nbsp;&nbsp;&nbsp; /// string aa = "1122我是中国人";<br />
&nbsp;&nbsp;&nbsp; /// CnCutString(aa,12,"...") &gt;&gt; 1122我...<br />
&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;<br />
&nbsp;&nbsp;&nbsp; /// &lt;param name="original"&gt;原始字符串&lt;/param&gt;<br />
&nbsp;&nbsp;&nbsp; /// &lt;param name="length"&gt;截取长度&lt;/param&gt;<br />
&nbsp;&nbsp;&nbsp; /// &lt;param name="fill"&gt;截取串小于原始串时,尾部附加字符串&lt;/param&gt;<br />
&nbsp;&nbsp;&nbsp; /// &lt;returns&gt;&lt;/returns&gt;<br />
&nbsp;&nbsp;&nbsp; public static String CnEnCutString(String original, Int32 length, String fill)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Regex CnRegex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Char[] CharArray = original.ToCharArray();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 tmplength = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Int32 i = 0; i &lt; CharArray.Length; i++)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmplength += CnRegex.IsMatch(CharArray[i].ToString()) ? 2 : 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tmplength &gt; length)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return original.Substring(0, i - fill.Length) + fill;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return original;<br />
&nbsp;&nbsp;&nbsp; }<br />
<br />
要加上命名空间：using System.Text.RegularExpressions;<br />
<br />
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1205995.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42134/" target="_blank">[新闻]JavaScript将成Silverlight的最大对手?</a>]]></description></item><item><title>ASP.NET IIS 注册工具 (Aspnet_regiis.exe)</title><link>http://www.cnblogs.com/kwongwah/archive/2008/05/16/1200288.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Fri, 16 May 2008 03:56:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/05/16/1200288.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1200288.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/05/16/1200288.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1200288.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1200288.html</trackback:ping><description><![CDATA[当在一台计算机上并行执行多个 .NET Framework 版本时，映射到 ASP.NET 应用程序的 ASP.NET ISAPI
版本决定了该应用程序所使用的公共语言运行库版本。ASP.NET IIS 注册工具 （Aspnet_regiis.exe）
使管理员或安装程序可以方便地更新 ASP.NET 应用程序的脚本映射，使其指向与该工具关联的 ASP.NET ISAPI
版本。该工具还可以用于显示所有已安装的 ASP.NET 版本的状态、注册与该工具耦合的 ASP.NET
版本、创建客户端脚本目录，以及执行其他配置操作。
<p>　　当您尝试调试的计算机上未正确安装 ASP.NET 时，会发生此错误。这可能意味着 ASP.NET 从未安装过，或者 ASP.NET 是在 IIS 之前安装的。</p>
<p>　　重新安装 ASP.NET</p>
<p>　　从命令提示窗口中，运行下列命令：</p>
<p>　　\WINNT\Microsoft.NET\Framework\version\aspnet_regiis -i</p>
<p>　　其中，version 是安装在您计算机上的 .NET Framework 的版本号（例如，v1.0.370）。</p>
<p>　　注意 对于 Windows Server 2003，可以使用&#8220;添加/删除程序&#8221;控制面板安装 ASP.NET.</p>
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1200288.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42133/" target="_blank">[新闻]没有谷歌就活不下去的四个网站</a>]]></description></item><item><title>在不同的事件中获得不同控件的主键</title><link>http://www.cnblogs.com/kwongwah/archive/2008/05/15/1199499.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Thu, 15 May 2008 15:38:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/05/15/1199499.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1199499.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/05/15/1199499.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1199499.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1199499.html</trackback:ping><description><![CDATA[datalist的 datalist_ItemCommand 得到主键：datalist.DataKeys[e.Item.ItemIndex];<br />
<br />
RadioButtonList得到绑定的Value RadioButtonList.SelectedValues;<br />
<br />
dropdownlist得到主键：<br />
<font face="Courier New">int id2=Convert.ToInt32(BranchDrop.SelectedValue);id = Convert.ToInt32(BranchDrop.SelectedItem.Value);</font><br />
<font face="Courier New"><br />
gridview(<font face="Courier New">RowDeleting</font>):<font face="Courier New">&nbsp; </font></font><br />
<font face="Courier New"><font face="Courier New">int id =Convert.ToInt32(gridview1.DataKeys[e.RowIndex].Value.ToString());<br />
</font><br />
<font face="Courier New">gridview1_RowEditing</font>:<font face="Courier New">&nbsp; </font></font><br />
<font face="Courier New"><font face="Courier New">id2 = Convert.ToInt32(gridview1.DataKeys[e.NewEditIndex].Value.ToString());</font><br />
<br />
Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)事件中获取主键：Gridview1.DataKeys[e.Row.RowIndex][0]<br />
<br />
在Gridview1_RowCommand事件中获取主键：<br />
<font color="#0000ff"><font color="black">Gridview1.DataKeys[Convert.ToInt32(e.CommandArgument)][0]<br />
</font></font><br />
datagrid_itemcommand: <br />
Dim ID As String = Me.datagrid1.dataKeys(e.item.itemIndex).toString() </font>
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1199499.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42132/" target="_blank">[新闻]Google 10周岁生日</a>]]></description></item><item><title>2008北京奥运，广州站</title><link>http://www.cnblogs.com/kwongwah/archive/2008/05/07/1187278.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Wed, 07 May 2008 10:50:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/05/07/1187278.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1187278.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/05/07/1187278.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1187278.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1187278.html</trackback:ping><description><![CDATA[<br />
来了，来了。火炬来了。<br />
<br />
火炬终于到来了.<object xcodebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" height="200" width="200"  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" >
<param name="Movie" value="/images/cnblogs_com/kwongwah/ssss.swf" />
<param name="Quality" value="high"/>
<param name="wmode" value="transparent"/><embed src="http://www.cnblogs.com/images/cnblogs_com/kwongwah/ssss.swf" width="200" height="200"  quality="high" wmode="transparent"     type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" ></embed>
</object><br />
<br />
呵，手机像素低了，但是还是见证了这一刻的场面，及人们的心情。<br />
<br />
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1187278.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42131/" target="_blank">[新闻]祝Google 10周岁生日快乐</a>]]></description></item><item><title>ASP.NET中常用的优化性能方法详解</title><link>http://www.cnblogs.com/kwongwah/archive/2008/04/30/1177283.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Wed, 30 Apr 2008 02:36:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/04/30/1177283.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1177283.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/04/30/1177283.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1177283.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1177283.html</trackback:ping><description><![CDATA[<p><strong>1. 数据库访问性能优化</strong> <br />
<br />
　　数据库的连接和关闭 <br />
<br />
　　访问数据库资源需要创建连接、打开连接和关闭连接几个操作。这些过程需要多次与数据库交换信息以通过身份验证，比较耗费服务器资源。ASP.NET中提供了连接池（Connection Pool）改善打开和关闭数据库对性能的影响。系统将用户的数据库连接放在连接池中，需要时取出，关闭时收回连接，等待下一次的连接请求。 </p>
<p>&nbsp;</p>
<p>　　连接池的大小是有限的，如果在连接池达到最大限度后仍要求创建连接，必然大大影响性能。因此，在建立数据库连接后只有在真正需要操作时才打开连接，使用完毕后马上关闭，从而尽量减少数据库连接打开的时间，避免出现超出连接限制的情况。 <br />
<br />
　　使用存储过程 <br />
<br />
　　存储过程是存储在服务器上的一组预编译的SQL语句，类似于DOS系统中的批处理文件。存储过程具有对数据库立即访问的功能，信息处理极为迅速。使用存储过程可以避免对命令的多次编译，在执行一次后其执行规划就驻留在高速缓存中，以后需要时只需直接调用缓存中的二进制代码即可。 <br />
<br />
　　另外，存储过程在服务器端运行，独立于ASP.NET程序，便于修改，最重要的是它可以减少数据库操作语句在网络中的传输。 <br />
<br />
　　优化查询语句 <br />
<br />
　　ASP.NET中ADO连接消耗的资源相当大，SQL语句运行的时间越长，占用系统资源的时间也越长。因此，尽量使用优化过的SQL语句以减少执行时间。比如，不在查询语句中包含子查询语句，充分利用索引等。 <br />
<br />
<strong>2. 字符串操作性能优化</strong> <br />
<br />
　　使用值类型的ToString方法 <br />
<br />
　　在连接字符串时，经常使用"+"号直接将数字添加到字符串中。这种方法虽然简单，也可以得到正确结果，但是由于涉及到不同的数据类型，数字需要通过装箱操作转化为引用类型才可以添加到字符串中。但是装箱操作对性能影响较大，因为在进行这类处理时，将在托管堆中分配一个新的对象，原有的值复制到新创建的对象中。 <br />
<br />
　　使用值类型的ToString方法可以避免装箱操作，从而提高应用程序性能。 <br />
<br />
　　运用StringBuilder类 <br />
<br />
　　String类对象是不可改变的，对于String对象的重新赋值在本质上是重新创建了一个String对象并将新值赋予该对象，其方法ToString对性能的提高并非很显著。 <br />
<br />
　　在处理字符串时，最好使用StringBuilder类，其.NET 命名空间是System.Text。该类并非创建新的对象，而是通过Append，Remove，Insert等方法直接对字符串进行操作，通过ToString方法返回操作结果。 <br />
<br />
　　其定义及操作语句如下所示： </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            int&nbsp;num;&nbsp; <br />
            <br />
            System.Text.StringBuilder&nbsp;str&nbsp;=&nbsp;new&nbsp;System.Text.StringBuilder();&nbsp;//创建字符串&nbsp; <br />
            <br />
            str.Append(num.ToString());&nbsp;//添加数值num&nbsp; <br />
            <br />
            Response.Write(str.ToString);&nbsp;//显示操作结果&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p><strong>3. 优化 Web 服务器计算机和特定应用程序的配置文件以符合您的特定需要</strong> <br />
<br />
　　默认情况下，ASP.NET 配置被设置成启用最广泛的功能并尽量适应最常见的方案。因此，应用程序开发人员可以根据应用程序所使用的功能，优化和更改其中的某些配置，以提高应用程序的性能。下面的列表是您应该考虑的一些选项。 <br />
<br />
　　仅对需要的应用程序启用身份验证。默认情况下，身份验证模式为 Windows，或集成 NTLM。大多数情况下，对于需要身份验证的应用程序，最好在 Machine.config 文件中禁用身份验证，并在 Web.config 文件中启用身份验证。 <br />
<br />
　　根据适当的请求和响应编码设置来配置应用程序。ASP.NET 默认编码格式为 UTF-8。如果您的应用程序为严格的 ASCII，请配置应用程序使用 ASCII 以获得稍许的性能提高。</p>
<p>　　考虑对应用程序禁用 AutoEventWireup。在 Machine.config 文件中将 AutoEventWireup 属性设置为 false，意味着页面不将方法名与事件进行匹配和将两者挂钩（例如 Page_Load）。如果页面开发人员要使用这些事件，需要在基类中重写这些方法（例如，需要为页面加载事件重写 Page.OnLoad，而不是使用 Page_Load 方法）。如果禁用 AutoEventWireup，页面将通过将事件连接留给页面作者而不是自动执行它，获得稍许的性能提升。 <br />
<br />
　　从请求处理管线中移除不用的模块。默认情况下，服务器计算机的 Machine.config 文件中 &lt;httpModules&gt; 节点的所有功能均保留为激活。根据应用程序所使用的功能，您可以从请求管线中移除不用的模块以获得稍许的性能提升。检查每个模块及其功能，并按您的需要自定义它。 <br />
<br />
　　例如，如果您在应用程序中不使用会话状态和输出缓存，则可以从 &lt;httpModules&gt;列表中移除它们，以便请求在不执行其他有意义的处理时，不必执行每个模块的进入和离开代码。 <br />
<br />
<strong>4. 一定要禁用调试模式</strong> <br />
<br />
　　在部署生产应用程序或进行任何性能测量之前，始终记住禁用调试模式。如果启用了调试模式，应用程序的性能可能受到非常大的影响。 <br />
<br />
<strong>5. 对于广泛依赖外部资源的应用程序，请考虑在多处理器计算机上启用网络园艺</strong> <br />
<br />
　　ASP.NET 进程模型帮助启用多处理器计算机上的可缩放性，将工作分发给多个进程（每个 CPU 一个），并且每个进程都将处理器关系设置为其 CPU。此技术称为网络园艺。如果应用程序使用较慢的数据库服务器或调用具有外部依赖项的 COM 对象（这里只是提及两种可能性），则为您的应用程序启用网络园艺是有益的。但是，在决定启用网络园艺之前，您应该测试应用程序在网络园中的执行情况。 <br />
<br />
<strong>6. 只要可能，就缓存数据和页输出</strong> <br />
<br />
　　ASP.NET 提供了一些简单的机制，它们会在不需要为每个页请求动态计算页输出或数据时缓存这些页输出或数据。另外，通过设计要进行缓存的页和数据请求（特别是在站点中预期将有较大通讯量的区域），可以优化这些页的性能。与 .NET Framework 的任何 Web 窗体功能相比，适当地使用缓存可以更好的提高站点的性能，有时这种提高是超数量级的。 <br />
<br />
　　使用 ASP.NET 缓存机制有两点需要注意。首先，不要缓存太多项。缓存每个项均有开销，特别是在内存使用方面。不要缓存容易重新计算和很少使用的项。其次，给缓存的项分配的有效期不要太短。很快到期的项会导致缓存中不必要的周转，并且经常导致更多的代码清除和垃圾回收工作。若关心此问题，请监视与 ASP.NET Applications 性能对象关联的 Cache Total Turnover Rate 性能计数器。高周转率可能说明存在问题，特别是当项在到期前被移除时。这也称作内存压力。 <br />
<br />
<strong>7. 选择适合页面或应用程序的数据查看机制</strong> <br />
<br />
　　根据您选择在 Web 窗体页显示数据的方式，在便利和性能之间常常存在着重要的权衡。例如，DataGrid Web 服务器控件可能是一种显示数据的方便快捷的方法，但就性能而言它的开销常常是最大的。在某些简单的情况下，您通过生成适当的 HTML 自己呈现数据可能很有效，但是自定义和浏览器定向会很快抵销所获得的额外功效。Repeater Web 服务器控件是便利和性能的折衷。它高效、可自定义且可编程。 <br />
<br />
<strong>8. 将 SqlDataReader 类用于快速只进数据游标</strong> <br />
<br />
　　SqlDataReader 类提供了一种读取从 SQL Server 数据库检索的只进数据流的方法。如果当创建 ASP.NET 应用程序时出现允许您使用它的情况，则 SqlDataReader 类提供比 DataSet 类更高的性能。情况之所以这样，是因为 SqlDataReader 使用 SQL Server 的本机网络数据传输格式从数据库连接直接读取数据。另外，SqlDataReader 类实现 IEnumerable 接口，该接口也允许您将数据绑定到服务器控件。有关更多信息，请参见 SqlDataReader 类。有关 ASP.NET 如何访问数据的信息，请参见通过 ASP.NET 访问数据。 <br />
<br />
<strong>9. 将 SQL Server 存储过程用于数据访问</strong> <br />
<br />
　　在 .NET Framework 提供的所有数据访问方法中，基于 SQL Server 的数据访问是生成高性能、可缩放 Web 应用程序的推荐选择。使用托管 SQL Server 提供程序时，可通过使用编译的存储过程而不是特殊查询获得额外的性能提高。<br />
<br />
</p>
<p><strong>10. 避免单线程单元 (STA) COM 组件</strong> <br />
<br />
　　默认情况下，ASP.NET 不允许任何 STA COM 组件在页面内运行。若要运行它们，必须在 .aspx 文件内将 ASPCompat=true 属性包含在 @ Page 指令中。这样就将执行用的线程池切换到 STA 线程池，而且使 HttpContext 和其他内置对象可用于 COM 对象。前者也是一种性能优化，因为它避免了将多线程单元 (MTA) 封送到 STA 线程的任何调用。 <br />
<br />
　　使用 STA COM 组件可能大大损害性能，应尽量避免。若必须使用 STA COM 组件，如在任何 interop 方案中，则应在执行期间进行大量调用并在每次调用期间发送尽可能多的信息。另外，小心不要在构造页面期间创建任何 STA COM 组件。例如下面的代码中，在页面构造时将实例化由某个线程创建的 MySTAComponent，而该线程并不是将运行页面的 STA 线程。这可能对性能有不利影响，因为要构造页面就必须完成 MTA 和 STA 线程之间的封送处理。 </p>
<p>&nbsp;</p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;%@&nbsp;Page&nbsp;Language="VB"&nbsp;ASPCompat="true"&nbsp;%&gt; <br />
            <br />
            &lt;script&nbsp;runat=server&gt;&nbsp; <br />
            <br />
            Dim&nbsp;myComp&nbsp;as&nbsp;new&nbsp;MySTAComponent()&nbsp; <br />
            <br />
            Public&nbsp;Sub&nbsp;Page_Load()&nbsp; <br />
            <br />
            myComp.Name&nbsp;=&nbsp;"Bob"&nbsp; <br />
            <br />
            End&nbsp;Sub&nbsp; <br />
            <br />
            &lt;/script&gt; <br />
            <br />
            &lt;html&gt; <br />
            <br />
            &lt;%&nbsp; <br />
            <br />
            Response.Write(myComp.SayHello)&nbsp; <br />
            <br />
            %&gt;&nbsp; <br />
            <br />
            &lt;/html&gt;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　首选机制是推迟对象的创建，直到以后在 STA 线程下执行上述代码，如下面的例子所示。 </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;%@&nbsp;Page&nbsp;Language="VB"&nbsp;ASPCompat="true"&nbsp;%&gt;&nbsp; <br />
            <br />
            &lt;script&nbsp;runat=server&gt;&nbsp; <br />
            <br />
            Dim&nbsp;myComp&nbsp; <br />
            <br />
            Public&nbsp;Sub&nbsp;Page_Load()&nbsp; <br />
            <br />
            myComp&nbsp;=&nbsp;new&nbsp;MySTAComponent()&nbsp; <br />
            <br />
            myComp.Name&nbsp;=&nbsp;"Bob"&nbsp; <br />
            <br />
            End&nbsp;Sub&nbsp; <br />
            <br />
            &lt;/script&gt;&nbsp; <br />
            <br />
            &lt;html&gt;&nbsp; <br />
            <br />
            &lt;%&nbsp; <br />
            <br />
            Response.Write(myComp.SayHello)&nbsp; <br />
            <br />
            %&gt;&nbsp; <br />
            <br />
            &lt;/html&gt;&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　推荐的做法是在需要时或者在 Page_Load 方法中构造任何 COM 组件和外部资源。 <br />
<br />
　　永远不要将任何 STA COM 组件存储在可以由构造它的线程以外的其他线程访问的共享资源里。这类资源包括像缓存和会话状态这样的资源。即使 STA 线程调用 STA COM 组件，也只有构造此 STA COM 组件的线程能够实际为该调用服务，而这要求封送处理对创建者线程的调用。此封送处理可能产生重大的性能损失和可伸缩性问题。在这种情况下，请研究一下使 COM 组件成为 MTA COM 组件的可能性，或者更好的办法是迁移代码以使对象成为托管对象。 <br />
<br />
<strong>11. 将调用密集型的 COM 组件迁移到托管代码</strong> <br />
<br />
　　.NET Framework 提供了一个简单的方法与传统的 COM 组件进行交互。其优点是可以在保留现有投资的同时利用新的平台。但是在某些情况下，保留旧组件的性能开销使得将组件迁移到托管代码是值得的。每一情况都是不一样的，决定是否需要迁移组件的最好方法是对 Web 站点运行性能测量。建议您研究一下如何将需要大量调用以进行交互的任何 COM 组件迁移到托管代码。 <br />
<br />
　　许多情况下不可能将旧式组件迁移到托管代码，特别是在最初迁移 Web 应用程序时。在这种情况下，最大的性能障碍之一是将数据从非托管环境封送到托管环境。因此，在交互操作中，请在任何一端执行尽可能多的任务，然后进行一个大调用而不是一系列小调用。例如，公共语言运行库中的所有字符串都是 Unicode 的，所以应在调用托管代码之前将组件中的所有字符串转换成 Unicode 格式。 <br />
<br />
　　另外，一处理完任何 COM 对象或本机资源就释放它们。这样，其他请求就能够使用它们，并且最大限度地减少了因稍后请求垃圾回收器释放它们所引起的性能问题。 <br />
<br />
<strong>12. 在 Visual Basic .NET 或 JScript 代码中使用早期绑定</strong> <br />
<br />
　　以往，开发人员喜欢使用 Visual Basic、VBScript 和 JScript 的原因之一就是它们所谓&#8220;无类型&#8221;的性质。变量不需要显式类型声明，并能够简单地通过使用来创建它们。当从一个类型到另一个类型进行分配时，转换将自动执行。不过，这种便利会大大损害应用程序的性能。<br />
<br />
　　Visual Basic 现在通过使用 Option Strict 编译器指令来支持类型安全编程。为了向后兼容，默认情况下，ASP.NET 不启用该选项。但是，为了得到最佳性能，强烈建议在页中启用该选项。若要启用 Option Strict，请将 Strict 属性包括在 @ Page 指令中，或者，对于用户控件，请将该属性包括在 @ Control 指令中。下面的示例演示了如何设置该属性，并进行了四个变量调用以显示使用该属性是如何导致编译器错误的。 </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;%@&nbsp;Page&nbsp;Language="VB"&nbsp;Strict="true"&nbsp;%&gt;&nbsp; <br />
            <br />
            &lt;%&nbsp; <br />
            <br />
            Dim&nbsp;B&nbsp; <br />
            <br />
            Dim&nbsp;C&nbsp;As&nbsp;String&nbsp; <br />
            <br />
            '&nbsp;This&nbsp;will&nbsp;cause&nbsp;a&nbsp;compiler&nbsp;error.&nbsp; <br />
            <br />
            A&nbsp;=&nbsp;"Hello"&nbsp; <br />
            <br />
            '&nbsp;This&nbsp;will&nbsp;cause&nbsp;a&nbsp;compiler&nbsp;error.&nbsp; <br />
            <br />
            B&nbsp;=&nbsp;"World"&nbsp; <br />
            <br />
            '&nbsp;This&nbsp;will&nbsp;not&nbsp;cause&nbsp;a&nbsp;compiler&nbsp;error.&nbsp; <br />
            <br />
            C&nbsp;=&nbsp;"!!!!!!"&nbsp; <br />
            <br />
            '&nbsp;But&nbsp;this&nbsp;will&nbsp;cause&nbsp;a&nbsp;compiler&nbsp;error.&nbsp; <br />
            <br />
            C&nbsp;=&nbsp;0&nbsp; <br />
            <br />
            %&gt;&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　JScript .NET 也支持无类型编程，但它不提供强制早期绑定的编译器指令。若发生下面任何一种情况，则变量是晚期绑定的： <br />
<br />
　　被显式声明为 Object。 <br />
<br />
　　是无类型声明的类的字段。 <br />
<br />
　　是无显式类型声明的专用函数或方法成员，并且无法从其使用推断出类型。 <br />
<br />
　　最后一个差别比较复杂，因为如果 JScript .NET 编译器可以根据变量的使用情况推断出类型，它就会进行优化。在下面的示例中，变量 A 是早期绑定的，但变量 B 是晚期绑定的。 </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            var&nbsp;A;&nbsp; <br />
            <br />
            var&nbsp;B;&nbsp; <br />
            <br />
            A&nbsp;=&nbsp;"Hello";&nbsp; <br />
            <br />
            B&nbsp;=&nbsp;"World";&nbsp; <br />
            <br />
            B&nbsp;=&nbsp;0;&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　为了获得最佳的性能，当声明 JScript .NET 变量时，请为其分配一个类型。例如，var A : String。</p>
<p><strong>13. 使请求管线内的所有模块尽可能高效</strong> <br />
<br />
　　请求管线内的所有模块在每次请求中都有机会被运行。因此，当请求进入和离开模块时快速地触发代码至关重要，特别是在不使用模块功能的代码路径里。分别在使用及不使用模块和配置文件时执行吞吐量测试，对确定这些方法的执行速度非常有用。 <br />
<br />
<strong>14. 使用 HttpServerUtility.Transfer 方法在同一应用程序的页面间重定向</strong> <br />
<br />
　　采用 Server.Transfer 语法，在页面中使用该方法可避免不必要的客户端重定向。 <br />
<br />
<strong>15. 必要时调整应用程序每个辅助进程的线程数</strong> <br />
<br />
　　ASP.NET 的请求结构试图在执行请求的线程数和可用资源之间达到一种平衡。已知一个使用足够 CPU 功率的应用程序，该结构将根据可用于请求的 CPU 功率，来决定允许同时执行的请求数。这项技术称作线程门控。但是在某些条件下，线程门控算法不是很有效。通过使用与 ASP.NET Applications 性能对象关联的 Pipeline Instance Count 性能计数器，可以在 PerfMon 中监视线程门控。 <br />
<br />
　　当页面调用外部资源，如数据库访问或 XML Web services 请求时，页面请求通常停止并释放 CPU。如果某个请求正在等待被处理，并且线程池中有一个线程是自由的，那么这个正在等待的请求将开始被处理。遗憾的是，有时这可能导致 Web 服务器上存在大量同时处理的请求和许多正在等待的线程，而它们对服务器性能有不利影响。通常，如果门控因子是外部资源的响应时间，则让过多请求等待资源，对 Web 服务器的吞吐量并无帮助。 <br />
<br />
　　为缓和这种情况，可以通过更改 Machine.config 配置文件
<processmodel></processmodel>
节点的 maxWorkerThreads 和 maxIOThreads 属性，手动设置进程中的线程数限制。 <br />
<br />
　　<u>注意</u> 辅助线程是用来处理 ASP.NET 请求的，而 IO 线程则是用于为来自文件、数据库或 XML Web services 的数据提供服务的。 <br />
<br />
　　分配给这些属性的值是进程中每个 CPU 每类线程的最大数目。对于双处理器计算机，最大数是设置值的两倍。对于四处理器计算机，最大值是设置值的四倍。无论如何，对于有四个或八个 CPU 的计算机，最好更改默认值。对于有一个或两个处理器的计算机，默认值就可以，但对于有更多处理器的计算机的性能，进程中有一百或两百个线程则弊大于利。 <br />
<br />
　　<u>注意</u> 进程中有太多线程往往会降低服务器的速度，因为额外的上下文交换导致操作系统将 CPU 周期花在维护线程而不是处理请求上。 <br />
<br />
<strong>16. 适当地使用公共语言运行库的垃圾回收器和自动内存管理</strong> <br />
<br />
　　小心不要给每个请求分配过多内存，因为这样垃圾回收器将必须更频繁地进行更多的工作。另外，不要让不必要的指针指向对象，因为它们将使对象保持活动状态，并且应尽量避免含 Finalize 方法的对象，因为它们在后面会导致更多的工作。特别是在 Finalize 调用中永远不要释放资源，因为资源在被垃圾回收器回收之前可能一直消耗着内存。最后这个问题经常会对 Web 服务器环境的性能造成毁灭性的打击，因为在等待 Finalize 运行时，很容易耗尽某个特定的资源。 <br />
<br />
<strong>17. 如果有大型 Web 应用程序，可考虑执行预批编译</strong> <br />
<br />
　　每当发生对目录的第一次请求时都会执行批编译。如果目录中的页面没有被分析并编译，此功能会成批分析并编译目录中的所有页面，以便更好地利用磁盘和内存。如果这需要很长时间，则将快速分析并编译单个页面，以便请求能被处理。此功能带给 ASP.NET 性能上的好处，因为它将许多页面编译为单个程序集。从已加载的程序集访问一页比每页加载新的程序集要快。 <br />
<br />
　　批编译的缺点在于：如果服务器接收到许多对尚未编译的页面的请求，那么当 Web 服务器分析并编译它们时，性能可能较差。为解决这个问题，可以执行预批编译。为此，只需在应用程序激活之前向它请求一个页面，无论哪页均可。然后，当用户首次访问您的站点时，页面及其程序集将已被编译。 <br />
<br />
　　没有简单的机制可以知道批编译何时发生。需一直等到 CPU 空闲或者没有更多的编译器进程（例如 csc.exe（C# 编译器）或 vbc.exe（Visual Basic 编译器））启动。 <br />
<br />
　　还应尽量避免更改应用程序的 \bin 目录中的程序集。更改页面会导致重新分析和编译该页，而替换 \bin 目录中的程序集则会导致完全重新批编译该目录。 <br />
<br />
　　在包含许多页面的大规模站点上，更好的办法可能是根据计划替换页面或程序集的频繁程度来设计不同的目录结构。不常更改的页面可以存储在同一目录中并在特定的时间进行预批编译。经常更改的页面应在它们自己的目录中（每个目录最多几百页）以便快速编译。 <br />
<br />
　　Web 应用程序可以包含许多子目录。批编译发生在目录级，而不是应用程序级。 <br />
<br />
<strong>18. 不要依赖代码中的异常</strong> <br />
<br />
　　因为异常大大地降低性能，所以您不应该将它们用作控制正常程序流程的方式。如果有可能检测到代码中可能导致异常的状态，请执行这种操作。不要在处理该状态之前捕获异常本身。常见的方案包括：检查 null，分配给将分析为数字值的 String 一个值，或在应用数学运算前检查特定值。下面的示例演示可能导致异常的代码以及测试是否存在某种状态的代码。两者产生相同的结果。 </p>
<p>&nbsp;</p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            try&nbsp; <br />
            <br />
            {&nbsp; <br />
            <br />
            result&nbsp;=&nbsp;100&nbsp;/&nbsp;num;&nbsp; <br />
            <br />
            }&nbsp; <br />
            <br />
            catch&nbsp;(Exception&nbsp;e)&nbsp; <br />
            <br />
            {&nbsp; <br />
            <br />
            result&nbsp;=&nbsp;0;&nbsp; <br />
            <br />
            }&nbsp; <br />
            <br />
            //&nbsp;...to&nbsp;this.&nbsp; <br />
            <br />
            if&nbsp;(num&nbsp;!=&nbsp;0)&nbsp; <br />
            <br />
            result&nbsp;=&nbsp;100&nbsp;/&nbsp;num;&nbsp; <br />
            <br />
            else&nbsp; <br />
            <br />
            result&nbsp;=&nbsp;0;&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p><strong>19. 使用 HttpResponse.Write 方法进行字符串串联</strong> <br />
<br />
　　该方法提供非常有效的缓冲和连接服务。但是，如果您正在执行广泛的连接，请使用多个 Response.Write 调用。下面示例中显示的技术比用对 Response.Write 方法的单个调用连接字符串更快。 </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            Response.Write("a");&nbsp; <br />
            <br />
            Response.Write(myString);&nbsp; <br />
            <br />
            Response.Write("b");&nbsp; <br />
            <br />
            Response.Write(myObj.ToString());&nbsp; <br />
            <br />
            Response.Write("c");&nbsp; <br />
            <br />
            Response.Write(myString2);&nbsp; <br />
            <br />
            Response.Write("d");&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p><strong>20. 除非有特殊的原因要关闭缓冲，否则使其保持打开</strong> <br />
<br />
　　禁用 Web 窗体页的缓冲会导致大量的性能开销。 <br />
<br />
<strong>21. 只在必要时保存服务器控件视图状态</strong> <br />
<br />
　　自动视图状态管理是服务器控件的功能，该功能使服务器控件可以在往返过程上重新填充它们的属性值（您不需要编写任何代码）。但是，因为服务器控件的视图状态在隐藏的窗体字段中往返于服务器，所以该功能确实会对性能产生影响。您应该知道在哪些情况下视图状态会有所帮助，在哪些情况下它影响页的性能。例如，如果您将服务器控件绑定到每个往返过程上的数据，则将用从数据绑定操作获得的新值替换保存的视图状态。在这种情况下，禁用视图状态可以节省处理时间。 <br />
<br />
　　默认情况下，为所有服务器控件启用视图状态。若要禁用视图状态，请将控件的EnableViewState 属性设置为 false，如下面的 DataGrid 服务器控件示例所示。 </p>
<p>&nbsp;</p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;asp:datagrid&nbsp;EnableViewState="false"&nbsp;datasource="..."&nbsp; runat="server"/&gt;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　您还可以使用 @ Page 指令禁用整个页的视图状态。当您不从页回发到服务器时，这将十分有用： </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;%@&nbsp;Page&nbsp;EnableViewState="false"&nbsp;%&gt;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　注意 @ Control 指令中也支持 EnableViewState 属性，该指令允许您控制是否为用户控件启用视图状态。 <br />
<br />
　　若要分析页上服务器控件使用的视图状态的数量，请（通过将 trace="true" 属性包括在 @ Page 指令中）启用该页的跟踪并查看 Control Hierarchy 表的 Viewstate 列。有关跟踪和如何启用它的信息，请参见 ASP.NET 跟踪。 <br />
<br />
<strong>22. 避免到服务器的不必要的往返过程</strong> <br />
<br />
　　虽然您很可能希望尽量多地使用 Web 窗体页框架的那些节省时间和代码的功能，但在某些情况下却不宜使用 ASP.NET 服务器控件和回发事件处理。 <br />
<br />
　　通常，只有在检索或存储数据时，您才需要启动到服务器的往返过程。多数数据操作可在这些往返过程间的客户端上进行。例如，从 HTML 窗体验证用户输入经常可在数据提交到服务器之前在客户端进行。通常，如果不需要将信息传递到服务器以将其存储在数据库中，那么您不应该编写导致往返过程的代码。 <br />
<br />
　　如果您开发自定义服务器控件，请考虑让它们为支持 ECMAScript 的浏览器呈现客户端代码。通过以这种方式使用服务器控件，您可以显著地减少信息被不必要的发送到 Web 服务器的次数。 <br />
<br />
　　使用 Page.IsPostBack 避免对往返过程执行不必要的处理 <br />
<br />
　　如果您编写处理服务器控件回发处理的代码，有时可能需要在首次请求页时执行其他代码，而不是当用户发送包含在该页中的 HTML 窗体时执行的代码。根据该页是否是响应服务器控件录傻模褂?Page.IsPostBack 属性有条件地执行代码。例如，下面的代码演示如何创建数据库连接和命令，该命令在首次请求该页时将数据绑定到 DataGrid 服务器控件。 </p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            void&nbsp;Page_Load(Object&nbsp;sender,&nbsp;EventArgs&nbsp;e)&nbsp; <br />
            <br />
            {&nbsp; <br />
            <br />
            //&nbsp;Set&nbsp;up&nbsp;a&nbsp;connection&nbsp;and&nbsp;command&nbsp;here.&nbsp; <br />
            <br />
            if&nbsp;(!Page.IsPostBack)&nbsp; <br />
            <br />
            {&nbsp; <br />
            <br />
            String&nbsp;query&nbsp;=&nbsp;"select&nbsp;*&nbsp;from&nbsp;Authors&nbsp;where&nbsp;FirstName&nbsp;like&nbsp;'%JUSTIN%'";&nbsp; <br />
            <br />
            myCommand.Fill(ds,&nbsp;"Authors");&nbsp; <br />
            <br />
            myDataGrid.DataBind();&nbsp; <br />
            <br />
            }&nbsp; <br />
            <br />
            }&nbsp;</td>
        </tr>
    </tbody>
</table>
</p>
<p><br clear="all" />
　　由于每次请求时都执行 Page_Load 事件，上述代码检查 IsPostBack 属性是否设置为 false。如果是，则执行代码。如果该属性设置为 true，则不执行代码。 <br />
<br />
　　<u>注意</u> 如果不运行这种检查，回发页的行为将不更改。Page_Load 事件的代码在执行服务器控件事件之前执行，但只有服务器控件事件的结果才可能在输出页上呈现。如果不运行该检查，仍将为 Page_Load 事件和该页上的任何服务器控件事件执行处理。 <br />
<br />
<strong>23. 当不使用会话状态时禁用它</strong> <br />
<br />
　　并不是所有的应用程序或页都需要针对于具体用户的会话状态，您应该对任何不需要会话状态的应用程序或页禁用会话状态。 <br />
<br />
　　若要禁用页的会话状态，请将 @ Page 指令中的 EnableSessionState 属性设置为 false。例如:</p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;%@&nbsp;Page&nbsp;EnableSessionState="false"&nbsp;%&gt;</td>
        </tr>
    </tbody>
</table>
</p>
<p>　　<u>注意</u> 如果页需要访问会话变量，但不打算创建或修改它们，则将 @ Page 指令中的 EnableSessionState 属性设置为 ReadOnly。 <br />
<br />
　　还可以禁用 XML Web services 方法的会话状态。有关更多信息，请参见使用 ASP.NET 和 XML Web services 客户端创建的 XML Web services。 <br />
<br />
　　若要禁用应用程序的会话状态，请在应用程序 Web.config 文件的 sessionstate 配置节中将 mode 属性设置为 off。例如:</p>
<p class="code">
<table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0">
    <tbody>
        <tr>
            <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片段：</font><br />
            &lt;sessionstate&nbsp;mode="off"&nbsp;/&gt;</td>
        </tr>
    </tbody>
</table>
</p>
<p><br />
<strong>24. 仔细选择会话状态提供程序</strong> <br />
<br />
　　ASP.NET 为存储应用程序的会话数据提供了三种不同的方法：进程内会话状态、作为 Windows 服务的进程外会话状态和 SQL Server 数据库中的进程外会话状态。每种方法都有自己的优点，但进程内会话状态是迄今为止速度最快的解决方案。如果只在会话状态中存储少量易失数据，则建议您使用进程内提供程序。进程外解决方案主要用于跨多个处理器或多个计算机缩放应用程序，或者用于服务器或进程重新启动时不能丢失数据的情况。有关更多信息，请参见 ASP.NET 状态管理。 <br />
<br />
<strong>25. 不使用不必要的Server Control <br />
</strong><br />
　　ASP.net中，大量的服务器端控件方便了程序开发，但也可能带来性能的损失，因为用户每操作一次服务器端控件，就产生一次与服务器端的往返过程。因此，非必要，应当少使用Server Control。 <br />
<br />
<strong>26. ASP.NET应用程序性能测试</strong> <br />
<br />
　　在对ASP.NET应用程序进行性能测试之前，应确保应用程序没有错误，而且功能正确。具体的性能测试可以采用以下工具进行： <br />
<br />
　　Web Application Strees Tool (WAS)是Microsoft发布的一个免费测试工具，可以从http://webtool.rte.microsoft.com/上下载。它可以模拟成百上千个用户同时对web应用程序进行访问请求，在服务器上形成流量负载，从而达到测试的目的，可以生成平均TTFB、平均TTLB等性能汇总报告。 <br />
<br />
　　Application Center Test (ACT) 是一个测试工具，附带于Visual Studio.NET的企业版中，是Microsoft正式支持的web应用程序测试工具。它能够直观地生成图表结果，功能比WAS多，但不具备多个客户机同时测试的能力。 <br />
&nbsp;&nbsp; 服务器操作系统"管理工具"中的"性能"计数器，可以对服务器进行监测以了解应用程序性能。 <br />
<strong>结论</strong> <br />
<br />
　　对于网站开发人员来说，在编写ASP.NET应用程序时注意性能问题，养成良好的习惯，提高应用程序性能，至少可以推迟必需的硬件升级，降低网站的成本。<br />
<br />
<br />
</p>
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1177283.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42130/" target="_blank">[新闻]Google十年市值达1500亿美元 创造奇迹</a>]]></description></item><item><title>在javascript中简单定义一个类class</title><link>http://www.cnblogs.com/kwongwah/archive/2008/04/29/1176915.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Tue, 29 Apr 2008 14:34:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/04/29/1176915.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1176915.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/04/29/1176915.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1176915.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1176915.html</trackback:ping><description><![CDATA[如下定义一个Student的类。里面有name和age两个属性和方法。<br />
function Student(){
<br />
this.name = "abc";
<br />
this.age = 16;
<br />
<br />
this.getName = function(){
<br />
return this.name;
<br />
}
<br />
this.getAge = function(){
<br />
return this.age;
<br />
}
<br />
}
<br />
<br />
使用
<br />
<br />
var s = new Student();
<br />
alert( s.getName() );
<br />
alert( s.getAge() );
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1176915.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42129/" target="_blank">[新闻]GMail:回过头来支持IE6</a>]]></description></item><item><title>C#类型转换问题－－整型</title><link>http://www.cnblogs.com/kwongwah/archive/2008/04/24/1169402.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Thu, 24 Apr 2008 07:10:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/04/24/1169402.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1169402.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/04/24/1169402.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1169402.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1169402.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.cnblogs.com/kwongwah/archive/2008/04/24/1169402.html'>阅读全文</a><img src ="http://www.cnblogs.com/kwongwah/aggbug/1169402.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42128/" target="_blank">[新闻]Google十年大变样</a>]]></description></item><item><title>C# 2.0  泛型</title><link>http://www.cnblogs.com/kwongwah/archive/2008/04/22/1165258.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Tue, 22 Apr 2008 03:20:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/04/22/1165258.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1165258.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/04/22/1165258.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1165258.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1165258.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.cnblogs.com/kwongwah/archive/2008/04/22/1165258.html'>阅读全文</a><img src ="http://www.cnblogs.com/kwongwah/aggbug/1165258.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42127/" target="_blank">[新闻]谷歌十年创新路</a>]]></description></item><item><title>windows2003中了一键还原7.9的招了</title><link>http://www.cnblogs.com/kwongwah/archive/2008/04/03/1136770.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Thu, 03 Apr 2008 11:56:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/04/03/1136770.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1136770.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/04/03/1136770.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1136770.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1136770.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 说真的，在中招的那一刻。我的心啊，真的好凉。想不到流氓一个。（在太平洋下载的一键还原软件7.9版本，文件名叫yjhy79.exe）<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; 在安装的过程中还满怀信心的，当我看到在选择备份的盘时，不让我选择强行跳过。那一刻就觉得不太对劲。为何不让我选择分区和盘呢？一勿一过～～真流氓。在一切安装完后一进系统。。。愣了。。。。。。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 系统竟然除了一个系统盘外，都发现不了盘符了。我的妈啊。我几年的数据都还在里头呢。咋办呢？这回。难道就让它这样给没了？你说是你你愿意吗？<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
后来我在&nbsp; 管理工具》计算机管理》存储》磁盘管理&nbsp;&nbsp;
里头看到了我的所有盘。只是没了盘符。空闲都是100%。一个字怪！！为何会这样呢？原来是都将我的符给隐藏了。后来我一
一给他们添上盘符后。一进去&#8220;我的电脑&#8221;果真有了。所有的盘都还在。里边的数据都还在。好极了。～～～<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 不过问题还是没结束，因为除系统盘外都是war格式了。（之前是fat32）难道是出于安全问题？不会啊。我的安全设置都没有设置，也找不到那一项。<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结果尝试重启一下看看。呵，这回真的真的<br />
&nbsp;&nbsp; &nbsp;&nbsp; 好了。好高兴。我不用发愁了。都自动变回了FAT32格式了。
<img src ="http://www.cnblogs.com/kwongwah/aggbug/1136770.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42126/" target="_blank">[新闻]十年回顾：Google的互联网经济</a>]]></description></item><item><title>welcome first!</title><link>http://www.cnblogs.com/kwongwah/archive/2008/03/15/1107089.html</link><dc:creator>Kwongwah</dc:creator><author>Kwongwah</author><pubDate>Sat, 15 Mar 2008 06:02:00 GMT</pubDate><guid>http://www.cnblogs.com/kwongwah/archive/2008/03/15/1107089.html</guid><wfw:comment>http://www.cnblogs.com/kwongwah/comments/1107089.html</wfw:comment><comments>http://www.cnblogs.com/kwongwah/archive/2008/03/15/1107089.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/kwongwah/comments/commentRss/1107089.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/kwongwah/services/trackbacks/1107089.html</trackback:ping><description><![CDATA[　　长久以来，都没什么时间来这里找个地方坐坐。现在，由于事务比较轻松了点。特来找个地方坐下。<br />
　　自我欢迎下。
 <img src ="http://www.cnblogs.com/kwongwah/aggbug/1107089.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/42123/" target="_blank">[新闻]Google 10周年大事记</a>]]></description></item></channel></rss>