﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>西奥气昂</title>
	<atom:link href="http://www.mvsay.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.mvsay.com</link>
	<description>闲谈杂扯</description>
	<lastBuildDate>Fri, 06 May 2011 08:11:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>ADO.NET Entity Framework: 由 Entity Object 執行 SQL 指令</title>
		<link>http://www.mvsay.com/?p=321</link>
		<comments>http://www.mvsay.com/?p=321#comments</comments>
		<pubDate>Fri, 06 May 2011 08:10:56 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Entity]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=321</guid>
		<description><![CDATA[•ObjectContext.ExecuteStoreCommand()：執行非資料提取式的 SQL 指令 (即 INSERT, UPDATE 與 DELETE)，並回傳受影響的資料列數。 
•ObjectContext.ExecuteStoreQuery<t>()：執行資料提取式的 SQL 指令 (即 SELECT)，並回傳一個指定型別的集合。 
•ObjectContext.Translate</t><t>()：將 DbDataReader 中的資料轉換成指定型別的物件。</t>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dotblogs.com.tw/regionbbs/archive/2010/02/16/netfx.4.0.new.feature.ado.net.entity.framework.2.0.directly.execute.sql.commands.aspx">http://www.dotblogs.com.tw/regionbbs/archive/2010/02/16/netfx.4.0.new.feature.ado.net.entity.framework.2.0.directly.execute.sql.commands.aspx</a></p>
<p>其實這個功能在 Entity Framework 中是有一點背道而馳的感覺。</p>
<p>不過就算是要做到像 POCO 這樣的全自動化 (無 SQL) 的資料存取元件，在一些特殊情況下，還是會動用到 SQL 指令來做一些事情，在 Entity Framework 1.0 中並沒有辦法這樣做，通常會以最傳統的 DbConnection 來連接資料庫後，才能使用 DbCommand 來存取資料庫，到了 .NET Framework 4.0，ADO.NET 團隊在 ObjectContext 中加入了三個方法，讓開發人員可以直接在 ObjectContext 上直接使用 SQL 指令來存取資料庫，並且神奇的是，它可以自動將資料填到指定的型別中。</p>
<p>這三個方法是：</p>
<p>•ObjectContext.ExecuteStoreCommand()：執行非資料提取式的 SQL 指令 (即 INSERT, UPDATE 與 DELETE)，並回傳受影響的資料列數。<br /> •ObjectContext.ExecuteStoreQuery&lt;T&gt;()：執行資料提取式的 SQL 指令 (即 SELECT)，並回傳一個指定型別的集合。<br /> •ObjectContext.Translate&lt;T&gt;()：將 DbDataReader 中的資料轉換成指定型別的物件。<br /> 而這三個方法可以讓開發人員在完全導入 Entity Framework ORM Solution 之前，可以有一個過渡的功能可利用，不用為了要做 ORM 而大幅改寫核心程式碼以融入 Entity Framework，並且提供對資料來源最直接的控制。</p>
<p>我們就以前面的文章：[VS2010] ADO.NET Entity Framework: 建立多對多關聯模型 所建立的資料模型，來玩玩看這些功能吧。</p>
<p>1. 測試傳回內建型別的資料，請在 Main 方法中加入下列程式碼並執行：</p>
<p>static void Main(string[] args)<br /> {<br /> &nbsp;&nbsp;&nbsp; using (SchoolDBContainer context = new SchoolDBContainer())<br /> &nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (string courseName in context.ExecuteStoreQuery&lt;string&gt;(&#8220;SELECT name FROM CoursesSet&#8221;) )<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&#8220;Course name: {0}&#8221;, courseName);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /> &nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; Console.ReadLine();<br /> }</p>
<p>你應該會看到類似這樣的輸出：</p>
<p>&nbsp;<img border="0" src="http://files.dotblogs.com.tw/regionbbs/1002/VS2010.NETEntityFrameworkEntityObjectSQL_12BB5/image_2.png" width="595" height="376"/><br /> ExecuteStoreQuery&lt;T&gt;() 透過傳入的 SQL 指令以及參數，將資料庫回傳的資料集以指定的型別來回傳，以上面的例子來說，就是把 CoursesSet 中的 name 屬性轉換成 string 型別的集合回傳，因為回傳的是一個 IEnumerate&lt;T&gt; 的集合，故可以直接使用 foreach 來巡覽並存取每個集合中的物件。它的第一個參數是 SQL 指令，第二個參數是 params 的參數陣列。ExecuteStoreQuery&lt;T&gt;() 可以支援的參數類型有三種：</p>
<p>1.使用 pattern 方式的參數指定，例如 ExecuteStoreQuery&lt;string&gt;(“SELECT name FROM CoursesSet WHERE CourseID = {0}”, 1234)，當然，這會有 SQL Injection 的問題，因此最好不要使用。<br /> 2.使用參數化查詢方式的參數指定，例如 ExecuteStoreQuery&lt;string&gt;(“SELECT name FROM CoursesSet WHERE CourseID = @p0”, 1234)，這是建議的作法。<br /> 3.若想要對參數有更進一步的控制，可以直接傳入 DbParameter 物件，例如 ExecuteStoreQuery&lt;string&gt;(“SELECT name FROM CoursesSet WHERE CourseID = @p0”, new SqlParameter( <a href="mailto:“@p0">“@p0</a> ”, 1234))。<br /> 2. 測試以類別裝載傳回的資料，請在 Main 方法中加入下列程式碼並執行：</p>
<p>public class Course<br /> {<br /> &nbsp;&nbsp;&nbsp; public string CourseID { get; set; }<br /> &nbsp;&nbsp;&nbsp; public string Name { get; set; }<br /> }</p>
<p>class Program<br /> {<br /> &nbsp;&nbsp;&nbsp; static void Main(string[] args)<br /> &nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (SchoolDBContainer context = new SchoolDBContainer())<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Course course in context.ExecuteStoreQuery&lt;Course&gt;(&#8220;SELECT * FROM CoursesSet&#8221;))<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&#8220;Course ID: {0}, name: {1}&#8221;, course.CourseID, course.Name);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.ReadLine();<br /> &nbsp;&nbsp;&nbsp; }<br /> }</p>
<p>你應該可以看到這個畫面：</p>
<p>&nbsp;<img border="0" src="http://files.dotblogs.com.tw/regionbbs/1002/VS2010.NETEntityFrameworkEntityObjectSQL_12BB5/image_4.png" width="597" height="401"/><br /> 如果要傳回的是一組資料，而且具有明確的類別物件，可以在 &lt;T&gt; 中設定該物件類別，由 ExecuteStoreQuery&lt;T&gt; 來自動幫我們將傳回的資料裝載到物件的屬性中，當然，該物件有幾個條件必須符合：</p>
<p>1.物件必須有預設無參數建構式，並且不是抽象類別。<br /> 2.屬性名稱必須要與欄位名稱對應。<br /> 3.屬性必須要是可讀寫 (read/write) 的。<br /> 若指定的類別中出現無法與欄位名稱對應的屬性時，ExecuteStoreQuery&lt;T&gt; 會略過該屬性的讀取，執行進行下一個屬性欄位的讀取，因此會發生資料遺漏的問題。</p>
<p>3. 測試非提取型 SQL 指令。請在 Main 中加入下列程式碼並執行：</p>
<p>public class Course<br /> {<br /> &nbsp;&nbsp;&nbsp; public string CourseID { get; set; }<br /> &nbsp;&nbsp;&nbsp; public string Name { get; set; }<br /> }</p>
<p>class Program<br /> {<br /> &nbsp;&nbsp;&nbsp; static void Main(string[] args)<br /> &nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (SchoolDBContainer context = new SchoolDBContainer())<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.ExecuteStoreCommand(&#8220;INSERT INTO CoursesSet (CourseID, Name) VALUES (@p0, @p1)&#8221;,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;C4&#8243;, &#8220;Database Concepts&#8221;);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Course course in context.ExecuteStoreQuery&lt;Course&gt;(&#8220;SELECT * FROM CoursesSet&#8221;))<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&#8220;Course ID: {0}, name: {1}&#8221;, course.CourseID, course.Name);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.ReadLine();<br /> &nbsp;&nbsp;&nbsp; }<br /> }</p>
<p>你應該可以看到下列畫面：</p>
<p>&nbsp;<img border="0" src="http://files.dotblogs.com.tw/regionbbs/1002/VS2010.NETEntityFrameworkEntityObjectSQL_12BB5/image_6.png" width="599" height="392"/></p>
<p>ExecuteStoreCommand() 與 ExecuteStoreQuery&lt;T&gt; 的方法差不多，但它是執行非提取型 SQL 指令，並回傳受影響的資料列數，如同 DbCommand.ExecuteNonQuery() 方法一樣。它的操作方式與 ExecuteStoreQuery&lt;T&gt; 相似，一樣可接受三種不同的參數，但筆者極強烈建議使用參數化查詢 。</p>
<p>4. 測試由 DbDataReader 轉換資料到物件。請在 Main 中加入下列程式碼並執行：</p>
<p>public class Course<br /> {<br /> &nbsp;&nbsp;&nbsp; public string CourseID { get; set; }<br /> &nbsp;&nbsp;&nbsp; public string Name { get; set; }<br /> }</p>
<p>class Program<br /> {<br /> &nbsp;&nbsp;&nbsp; static void Main(string[] args)<br /> &nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlConnection connection = new SqlConnection(<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Data Source=.;Initial Catalog=AdoEF_Example;Integrated Security=True;MultipleActiveResultSets=True&#8221;);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.Open();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlCommand cmd = new SqlCommand(&#8220;SELECT * FROM CoursesSet&#8221;, connection);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SqlDataReader reader = cmd.ExecuteReader();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (SchoolDBContainer context = new SchoolDBContainer())<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Course course in context.Translate&lt;Course&gt;(reader) )<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&#8220;Course ID: {0}, name: {1}&#8221;, course.CourseID, course.Name);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader.Close();<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.Close();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.ReadLine();<br /> &nbsp;&nbsp;&nbsp; }<br /> }</p>
<p>你應該可以看到下列畫面：</p>
<p>&nbsp;<img border="0" src="http://files.dotblogs.com.tw/regionbbs/1002/VS2010.NETEntityFrameworkEntityObjectSQL_12BB5/image_6.png" width="603" height="389"/></p>
<p>Translate&lt;T&gt;() 方法的行為和 ExecuteStoreQuery&lt;T&gt; 類似，它雖然不是直接執行 SQL 指令，但它是可以允許開發人員使用原有的 ADO.NET 物件模型，呼叫 DbCommand.ExecuteReader() 傳回的 DbDataReader 轉換成指定型別的一個方法，而 ExecuteStoreQuery&lt;T&gt; 內部就是使用這個方法來轉換資料結果集到指定物件的。</p>
<p>參考資料：</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ee358758%28VS.100%29.aspx">Directly Executing Store Commands</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ee358769%28VS.100%29.aspx">How to: Directly Execute Commands Against the Data Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=321</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>哈佛有一个著名的理论</title>
		<link>http://www.mvsay.com/?p=317</link>
		<comments>http://www.mvsay.com/?p=317#comments</comments>
		<pubDate>Mon, 28 Mar 2011 09:16:22 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[IamV]]></category>
		<category><![CDATA[养生]]></category>
		<category><![CDATA[学习方法]]></category>
		<category><![CDATA[家]]></category>
		<category><![CDATA[工作]]></category>
		<category><![CDATA[心理效应]]></category>
		<category><![CDATA[管理]]></category>
		<category><![CDATA[经济]]></category>
		<category><![CDATA[追求幸福]]></category>
		<category><![CDATA[道理]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=317</guid>
		<description><![CDATA[【唯美爱情电影你看过哪些？】《假如爱有天意》《夏天协奏曲》《雏菊》《恋空》《海角七号》《情书》《触不到的恋人》《四月物语》《我脑海中的橡皮擦》《天使之恋》《比悲伤更悲伤的故事》《听说》《云中漫步》《七音符》《八月照相馆》《现在只想爱你》《恋爱小说》《向左爱向右爱》]]></description>
			<content:encoded><![CDATA[<p>经典语录一:<br /> &nbsp;&nbsp;&nbsp; 哈佛有一个著名的理论：人的差别在于业余时间，而一个人的命运决定于晚上8点到10点之间。每晚抽出2个小时的时间用来阅读、进修、思考或参加有意的演讲、讨论，你会发现，你的人生正在发生改变，坚持数年之后，成功会向你招手。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录二:<br /> &nbsp;&nbsp;&nbsp; 无论你的收入是多少，记得分成五份进行规划投资：增加对身体的投资，让身体始终好用；增加对社交的投资，扩大你的人脉；增加对学习的投资，加强你的自信；增加对旅游的投资，扩大你的见闻；增加对未来的投资，增加你的收益。好好规划落实，你会发现你的人生逐步会有大量盈余。<br /> &nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录三:<br /> &nbsp;&nbsp;&nbsp; 过去的一页，能不翻就不要翻，翻落了灰尘会迷了双眼。有些人说不出哪里好，但就是谁都替代不了! 那些以前说着永不分离的人，早已经散落在天涯了。收拾起心情，继续走吧，错过花，你将收获雨，错过这一个，你才会遇到下一个。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录四:<br /> &nbsp;&nbsp;&nbsp; 被人误解的时候能微微的一笑，这是一种素养；受委屈的时候能坦然的一笑，这是一种大度；吃亏的时候能开心的一笑，这是一种豁达；无奈的时候能达观的一笑，这是一种境界；危难的时候能泰然一笑，这是一种大气；被轻蔑的时候能平静的一笑，这是一种自信；失恋的时候能轻轻的一笑，这是一种洒脱。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录五:<br /> &nbsp;&nbsp;&nbsp; 人生途中，有些是无法逃避的，比如命运；有些是无法更改的，比如情缘；有些是难以磨灭的，比如记忆；有些是难以搁置的，比如爱恋……与其被动地承受，不如勇敢地面对；与其鸟宿檐下，不如击翅风雨；与其在沉默中孤寂，不如在抗争中爆发……路越艰，阻越大，险越多，只要走过去了，人生就会更精彩。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录六:<br /> &nbsp;&nbsp;&nbsp; 你改变不了环境，但你可以改变自己；你改变不了事实，但你可以改**度；你改变不了过去，但你可以改变现在；你不能控制他人，但你可以掌握自己；你不能预知明天，但你可以把握今天；你不可以样样顺利，但你可以事事尽心；你不能延伸生命的长度，但你可以决定生命的宽度。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录七:<br /> &nbsp;&nbsp;&nbsp; 魅力女人：1、善于发现生活里的美。2、养成看书的习惯。3、拥有品位。4、跟有思想的人交朋友。5、远离泡沫偶像剧。6、学会忍耐与宽容。7、培养健康的心态，重视自己的身体。8、离开任何一个男人，都会活得很好。9、有着理财的动机，学习投资经营。10、尊重感情，珍惜缘分。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录八:<br /> &nbsp;&nbsp;&nbsp; 愚人向远方寻找快乐，智者则在自己身旁培养快乐。生活里的每一个细节都蕴藏着快乐，只是在于你是否感受到了而已。快乐着的人，每一件事，每一个人身上，他都能发现能令自己欢悦的因素来，并让快乐扩张，鼓舞和影响了周围的人。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录九:<br /> &nbsp;&nbsp;&nbsp; 【给自己安慰的10句温馨话】1、最重要的是今天的心；2、别总是自己跟自己过不去；3、用心做自己该做的事；4、不要过于计较别人评价；5、每个人都有自己的活法；6、喜欢自己才会拥抱生活；7、不必一味讨好别人；8、木已成舟便要顺其自然；9、不妨暂时丢开烦心事；10、自己感觉幸福就是幸福。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录十:<br /> &nbsp;&nbsp;&nbsp; 没有永远的缘份，没有永远的生命，我们所能拥有的，可能只是平凡的一生。然而因为有你，生命便全然不同，不用誓言，不必承诺，我们只需依了爱缘，以目光为媒，印证三生石上的约定，便牵了手，不必紧握，却永不放松，以自己设计的爱的程式，去演绎一种精典的永恒。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录十一:<br /> &nbsp;&nbsp;&nbsp; 我们之所以会心累，就是常常徘徊在坚持和放弃之间，举棋不定。我们之所以会烦恼，就是记性太好，该记的，不该记的都会留在记忆里。我们之所以会痛苦，就是追求的太多。我们之所以不快乐，就是计较的太多，不是我们拥有的太少，而是我们计较的太多。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录十二:<br /> &nbsp;&nbsp;&nbsp; 男人吸引女人的10个特质:1.真实 2.深刻 3.胸怀 4.敢为 5.风度 6.机灵 7.幽默 8.进取 9.浪漫 10.冒险.女人吸引男人的10个特点:1.温柔 2.知性 3.直性 4.涵养 5.朦胧 6.小动作 7.勤于家事 8.肤白 9.性感着装 10.香氛</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录十三:<br /> &nbsp;&nbsp;&nbsp; 真正的爱，是接受，不是忍受；是支持，不是支配；是慰问，不是质问；真正的爱，要道谢也要道歉。要体贴，也要体谅。要认错，也好改错；真正的爱，不是彼此凝视，而是共同沿着同一方向望去。其实，爱不是寻找一个完美的人。而是，要学会用完美的眼光，欣赏一个并不完美的人。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录十四:<br /> &nbsp;&nbsp;&nbsp; 身边总有些人，你看见他整天都开心，率真得像个小孩，人人都羡慕他；其实，你哪里知道：前一秒人后还伤心地流着泪的他，后一秒人前即刻洋溢灿烂笑容。他们其实没有能力独处，夜深人静时，总坐在窗前对着夜空冥想失意的苦楚。他们就像向日葵，向着太阳的正面永远明媚鲜亮，在照不到的背面却将悲伤深藏。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录十五:<br /> &nbsp;&nbsp;&nbsp; 生命中，有些人来了又去，有些人去而复返，有些人近在咫尺，有些人远在天涯，有些人擦身而过，有些人一路同行。或许在某两条路的尽头相遇，结伴同行了一段路程，又在下一个分岔路口道别。无论如何，终免不了曲终人散的伤感。远在天涯的朋友：或许已是遥远得无法问候，但还是谢谢您曾经的结伴同行。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录十六:<br /> &nbsp;&nbsp;&nbsp; 爱情很简单，因为每个人都会说：“我爱你，会为你付出一切！”，爱情很难，因为没有多少人做到了他的承诺。 如果真心爱一个人，不承诺也会去爱；如果不爱一个人，曾经承诺也会背叛。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录十七:<br /> &nbsp;&nbsp;&nbsp; 【你最后悔什么】某杂志对全国60岁以上的老人抽样调查：第一名：75％的人后悔年轻时努力不够，导致一事无成。第二名：70％的人后悔在年轻的时候选错了职业。第三名：62％的人后悔对子女教育不当。第四名：57％的人后悔没有好好珍惜自己的伴侣。第五名：49％的人后悔没有善待自己的身体。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录十八:<br /> &nbsp;&nbsp;&nbsp; 【做人十心机】⒈做人不能太单纯 适度伪装自己 ⒉凡事留余地 要留退路 ⒊话不说绝 口无遮拦难成大事 ⒋成熟而不世故 ⒌心态好 想得开活得不累 ⒍懂方圆之道：没事不惹事，来事不怕事 ⒎不可少二礼:礼仪与礼物 ⒏人在江湖飘 防挨朋友刀 ⒐偶尔&#8221;势利眼&#8221; 寻可靠伙伴 ⒑放下面子来做人。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录十九:<br /> &nbsp;&nbsp;&nbsp; 人生旅途中，总有人不断地走来，有人不断地离去。当新的名字变成老的名字，当老的名字渐渐模糊，又是一个故事的结束和另一个故事的开始。在不断的相遇和错开中，终于明白：身边的人只能陪着自己走过或近或远的一程，而不能伴自己一生；陪伴一生的是自己的名字和那些或清晰或模糊的名字所带来的感动。</p>
<p>&nbsp;&nbsp;&nbsp; 经典语录二十:<br /> &nbsp;&nbsp;&nbsp; 从现在开始，聪明一点，不要问别人想不想你，爱不爱你？若是要想你或者爱你自然会对你说，但是从你的嘴里说出来，别人会很骄傲和不在乎你。再也不要太在意一些人，太在乎一些事，顺其自然以最佳心态面对，因为这个世界就是这样：往往在最在乎的事物面前，我们最没有价值。</p>
<p> &nbsp;&nbsp;&nbsp; 经典语录二十一:<br /> &nbsp;&nbsp;&nbsp; 一个人的成就，不是以金钱衡量，而是一生中，你善待过多少人，有多少人怀念你。生意人的账簿，记录收入与支出，两数相减，便是盈利。人生的账簿，记录爱与被爱，两数相加，就是成就。</p>
<p> 【唯美爱情电影你看过哪些？】《假如爱有天意》《夏天协奏曲》《雏菊》《恋空》《海角七号》《情书》《触不到的恋人 》《四月物语》《我脑海中的橡皮擦》《天使之恋》《比悲伤更悲伤的故事》《听说》《云中漫步》《七音符》《八月照相 馆》《现在只想爱你》《恋爱小说》《向左爱向右爱》</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=317</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>记忆力当掉了</title>
		<link>http://www.mvsay.com/?p=315</link>
		<comments>http://www.mvsay.com/?p=315#comments</comments>
		<pubDate>Mon, 28 Mar 2011 07:47:10 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[IamV]]></category>
		<category><![CDATA[养生]]></category>
		<category><![CDATA[心理效应]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=315</guid>
		<description><![CDATA[记忆，就是过去的经验在人脑中的反映。它包括识记、保持、再现、回忆三个基本过程。 
其形式有形象记忆、概念记忆、逻辑记忆、情绪记忆、运动记忆等。 
记忆的大敌是遗忘。提高记忆力，实际就是尽量避免和克服遗忘。在学习活动中只要进行有意识的锻炼，掌握记忆规律和方法，就能改善和提高记忆力。下面介绍增强记忆的十种方法。 
]]></description>
			<content:encoded><![CDATA[<p>怎样增强记忆力？<br /> 记忆，就是过去的经验在人脑中的反映。它包括识记、保持、再现、回忆三个基本过程。<br /> 其形式有形象记忆、概念记忆、逻辑记忆、情绪记忆、运动记忆等。<br /> 记忆的大敌是遗忘。提高记忆力，实际就是尽量避免和克服遗忘。在学习活动中只要进行有意识的锻炼，掌握记忆规律和方法，就能改善和提高记忆力。下面介绍增强记忆的十种方法。<br /> 1.注意集中。记忆时只要聚精会神、专心致志，排除杂念和外界干扰，大脑皮层就会留下深刻的记忆痕迹而不易遗忘。如果精神涣散，一心二用，就会大大降低记忆效率。<br /> 2.兴趣浓厚。如果对学习材料、知识对象索然无味，即使花再多时间，也难以记住。<br /> 3.理解记忆。理解是记忆的基础。只有理解的东西才能记的牢、记得久。仅靠死记硬背，则不容易记住。对于重要的学习内容，如能作到理解和背诵相结合，记忆效果会更好。<br /> 4.过度学习。即对学习材料在记住的基础上，多记几遍，达到熟记、牢记的程度。过度学习的最佳程度是150%。<br /> 5.及时复习。遗忘的速度是先快后慢。对刚学过的知识，趁热打铁，及时温习巩固，是强化记忆痕迹、防止遗忘的有效手段。<br /> 6.经常回忆。学习时，不断进行尝试回忆，可使记忆错误得到纠正，遗漏得到弥补，使学习内容难点记的更牢。闲暇时经常回忆过去识记的对象，也能避免遗忘。<br /> 7.读、想、视、听相结合。可以同时利用语言功能和视听觉器官的功能，来强化记忆，提高记忆效率，比单一默读效果好的多。<br /> 8.运用多种记忆手段。根据情况，灵活运用分类记忆、特点记忆、谐音记忆、争论记忆、联想记忆、趣味记忆、图表记忆、缩短记忆及编提纲、做笔记、卡片等记忆方法，均能增强记忆力。<br /> 9.掌握最佳记忆时间。一般来说，上午9～11时，下午3～4时，晚上7～10时，为最佳记忆时间。利用上述时间记忆难记的学习材料，效果较好。<br /> 10.科学用脑。在保证营养、积极休息、进行体育锻炼等保养大脑的基础上，科学用脑，防止过度疲劳，保持积极乐观的情绪，能大大提高大脑的工作效率。这是提高记忆力的关键。</p>
<p>使注意力集中的方法和训练<br /> 两项大满贯得主玛丽皮尔斯在获97年意大利公开赛冠军后曾说过这样一段话：“我花了很长的时间来训练我集中注意力的能力，现在我已经开始感觉到在这一方面的提高了。我想关键是在于不去想过去和将来，不去想你会输或者赢。在这以前我总是不能控制自己去想这些事情。现在我所想的就是尽我最大的能力，做得最好。当我能做到这一点的时候，我就能打好球了。”<br /> 保持注意力集中<br /> 按照皮尔斯所说，把注意力集中在现在，也就是集中在比赛中的能力，就是“不去想过去和将来”的能力。<br /> 从根本上来说，注意力集中就是保持三个统一：<br /> 1，个体的统一 我只想自己。<br /> 2，地点的统一 我在这里。<br /> 3，时间的统一 我在现在。<br /> 听到选手这样的抱怨是很平常的：“我总是注意周围的人。”或者“今天我不知道自己在哪儿。”，或者“在整个第二盘，我完全不能集中自己的注意力，因为我总是想着在第一盘的盘点时，我打丢的那个很容易的截击。”<br /> 在上面的三个例子中，很明显个体的统一（自己），地点的统一（这里），时间的统一（现在），没有被遵守，这就是选手注意力不能集中的原因。这就是我们所说的不能集中注意力。<br /> 下面是对注意力集中机制的总结：<br /> 个体的统一 自己——他人<br /> 注意力集中 地点的统一 这里——别处<br /> 时间的统一 过去——现在——将来<br /> 我们可以进一步总结为： 自己 这里 现在<br /> 如果你在一场比赛中不能集中注意力，你一定是在这三个方面的一个或几个方面出了问题。首先知道是在哪个方面出了问题非常重要，下面是鉴别的方法：<br /> 1，是否你周围的人使你注意力分散：观众，对手，裁判，隔壁场地的选手，父母，朋友，或教练等等。<br /> 2，你的思绪是否跑到了别处：隔壁场地，你的家，办公室，学校，俱乐部等等。<br /> 3，是否你的思绪回到了过去（刚才你才丢的那一分），或者你在想将来的事（下一个你想要参加的巡回赛，如果你输了，你就失去机会了。）<br /> 发现你注意力不集中的原因是使你注意力再度集中的关键，下一步就是把注意力集中到：<br /> 自己 这里 现在<br /> 那么象注意力这样无形的东西，又是怎样在比赛中发挥作用？而注意力又在选手的比赛中扮演什么样的角色呢？<br /> 集中注意力说白了，就是把注意力集中在一个选手所拥有的技术，战术，生理和心理的能量上。我们可以用激光的例子来做个简单的说明：拿一束分散的光，我们把它集中到一个点，然后压缩压缩再压缩到极限，我们就获得了一束激光。激光的能量之强足以能切割钢铁。那完全的注意力的集中也和激光一样的威力无穷。完全的注意力集中能成倍的使你有意识的能量得到完美发挥的同时，它还能激发你无意识的能量，包括你的创造力，你的直觉。当你听到一个选手说：“我状态好得不得了。”或者“今天我什么球都有，感觉真是棒极了。”那就是说他或者她在经历着注意力非常集中的阶段。那些真正的冠军经历这种阶段的次数远比其他选手经历的次数多得多。这就是他们为什么总能超越自我，充分发挥的原因。<br /> 那又是什么使他们能达到这种注意力完全集中的境界呢？他们是不是天生就有这种能力呢？当然，每个人在出生后就有着个体的不同，集中注意力的能力也有区别。但皮尔斯已经告诉你了，你可以花时间去训练和提高它。所以唯一你需要做得就是练习。</p>
<p>练习<br /> 你所要练习的就是把你的注意力集中到特定的也是唯一的物体上，关键是：一个物体，只有一个。下面就是你在比赛中可以把注意力集中于的物体：<br /> 在对打中：<br /> ——球<br /> ——球在球场上的弹跳声和击球声<br /> ——你的呼吸<br /> 分与分之间：<br /> ——拍弦<br /> ——对自己重复的一个字或一句话<br /> ——你的呼吸<br /> 你的大脑必须完全被你的注意力所集中于的物体填满，不能有其他的有意识的东西进入。</p>
<p>训练方法<br /> 五个在场下训练注意力集中的方法：<br /> 1，拿一个网球，把它放在你面前，盯着它看，把你的注意力完全集中在它的上面。让你的脑子里只有这个网球，试着逐渐增加训练的时间。（外部视觉的）<br /> 2，闭上双眼，用你的想象来想象这个球，并把注意力集中在上面，试着逐渐增加训练的时间。（内部视觉的）<br /> 3，拿一个节拍器，打开它，把你的注意力集中在节奏上，让你的脑子里充满这个节奏，如果你的脑子里有别的东西出现，就让它象一片云一样飘过。（外部听觉的）<br /> 4，选一句话或一个字，最好是比较积极的，然后重复对自己说。在你的脑子里象放录音一样一遍遍地反复。试着逐渐增加训练的时间。（内部听觉的）<br /> 5，注意你的呼吸。去感觉空气进出你的肺，并且让呼吸使你平静。每一次你吸气时，就好象你使你注意力集中的能力增大，每一次呼气时，就好象把其他的杂念都呼了出去。用鼻子吸气，用嘴呼气。（外部听觉的和内部动觉的）<br /> 五个在场上训练注意力集中的方法：<br /> 1，把注意力集中在飞行中的球上。让你的脑子里充满这个运动的球，别让别的东西进入。保持注意力并全部集中在球上。（外部视觉的）<br /> 2，把你的注意力集中在球的弹跳声或你和你的对手的击球声上，并跟上这个节奏。（外部听觉的）<br /> 3，当你对手击球的时候吸气，当你击球的时候呼气。把注意力集中在呼吸上，并让呼吸使你平静。（内部动觉的和外部听觉的）<br /> 4，在对打过程中，在击球前，在心里对自己说“进攻”，“迎上去”或者类似的话，让这句话充满你的脑子。（内部听觉的）<br /> 5，在分与分之间，让一个不动的或动的想象的形象出现在你的脑子里，比如一个特别的战术安排，或你自己充满斗志的形象。你还可以想象在你的脑子里出现“镇静”，“COME ON”等等字句，这些字句必须比较短，才能更容易把注意力完全集中在它上面。</p>
<p> 12种能增强记忆力的食品</p>
<p>人大脑中有无数亿个神经细胞在不停的进行着繁重的活动，科学研究证实，饮食不仅是维持生命的必需品，而且在大脑正常运转中也发挥着十分重要的作用。有些食物有助于发展人的智力，使人的思维更加敏捷，精力更为集中，甚至能够激发人的创造力和想象力。<br /> 营养保健专家研究发现，一些有助于补脑健智的食品，并非昂贵难觅，而恰恰是廉价又普通之物，日常生活随处可见。以下几种食品就对大脑十分有益，脑力劳动者、在校学生不妨经常选食。<br /> 1、牛奶。牛奶是一种近乎完美的营养品。它富含蛋白质、钙，及大脑所必需的氨基酸。牛奶中的钙最易被人吸收，是脑代谢不可缺少的重要物质。此外，它还含对神经细胞十分有益的维生素B1等元素。如果用脑过度而失眠时，睡前一杯热牛奶有助入睡。<br /> 2、鸡蛋。大脑活动功能，记忆力强弱与大脑中乙酰胆碱含量密切相关。实验证明，吃鸡的妙处在于：当蛋黄中所含丰富的卵磷脂被酶分解后，能产生出丰富的乙酰胆碱，进入血液又会很快到达脑组织中，可增强记忆力。国外研究证实，每天吃1、2只鸡蛋就可以向机 体供给足够的胆碱，对保护大脑，提高记忆力大有好处。<br /> 3、鱼类。它们可以向大脑提供优质蛋白质和钙，淡水鱼所含的脂肪酸多为不饱和脂肪酸，不会引起血管硬化，对脑动脉血管无危害，相反，还能保护脑血管、对大脑细胞活动有促进作用。<br /> 4、味精。味精的主要成分是谷氨酸钠，它在胃酸的作用下可转化为谷氨酸。谷氨酸是参加人体脑代谢的唯一氨基酸，能促进智力发育，维持和改进大脑机能。常摄入些味精，对改善智力不足及记忆力障碍有帮助。由于味精会使脑内乙酰胆碱增加，因而对神经衰弱症也 有一定疗效。<br /> 5、花生。花生富含卵磷脂和脑磷脂，它是神经系统所需要的重要物质，能延缓脑功能衰退，抑制血小板凝集，防止脑血栓形成。实验证实，常食花生可改善血液循环、增强记忆、延缓衰老，是名符其实的“长生果”。<br /> 6、小米。小米中所含的维生素B1和B2分别高于大米1.5倍和1倍，其蛋白质中含较多的色氨酸和蛋氨酸。临床观察发现，吃小米有防止衰老的作用。如果平时常吃点小米粥、小米饭，将益于脑的保健。<br /> 7、玉米。玉米胚中富含亚油酸等多种不饱和脂肪酸，有保护脑血管和降血脂作用。尤其是玉米中含水量谷氨酸较高，能帮助促进脑细胞代谢，常吃些玉米尤其是鲜玉米，具有健脑作用。<br /> 8、黄花菜。人们常说，黄花菜是“忘忧草”，能“安神解郁”。注意：黄花菜不宜生吃或单炒，以免中毒，以干品和煮熟吃为好。<br /> 9、辣椒。辣椒维生素C含量居各蔬菜之首，胡萝卜素和维生素含量也很丰富。辣椒所含的辣椒碱能刺激味觉、增加食欲、促进大脑血液循环。近年有人发现，辣椒的“辣”味还是刺激人体内追求事业成功的激素，使人精力充沛，思维活跃。辣椒以生吃效果更好。<br /> 10、菠菜。菠菜虽廉价而不起眼，但它属健脑蔬菜。由于菠菜中含有丰富的维生素A、C、B1和B2，是脑细胞代谢的“最佳供给者”之一。此外，它还含有大量叶绿素，也具有健脑益智作用。<br /> 11、橘子。橘子含有大量维生素A、B1和C，属典型的碱性食物，可以消除大量酸性食物对神经系统造成的危害。考试期间适量常吃些橘子，能使人精力充沛。此外，柠檬、广柑、柚子等也有类似功效，可代替橘子。<br /> 12、菠萝。菠萝含有很多维生素C和微量元素锰，而且热量少，常吃有生津、提神的作用，有人称它是能够提高人记忆力的水果。菠萝常是一些音乐家、歌星和演员最喜欢的水果，因为他们要背诵大量的乐谱、歌词和台词。</p>
<p>&nbsp;</p>
<p>保持良好的注意力，是大脑进行感知、记忆、思维等认识活动的基本条件。在我们的学习过程中，注意力是打开我们心灵的门户，而且是唯一的门户。门开得越大，我们学到的东西就越多。而一旦注意力涣散了或无法集中，心灵的门户就关闭了，一切有用的知识信息都无法进入。正因为如此，法国生物学家乔治.居维叶说：“天才，首先是注意力。”</p>
<p>在正常情况下，注意力使我们的心理活动朝向某一事物，有选择地接受某些信息，而抑制其它活动和其它信息，并集中全部的心理能量用于所指向的事物。因而，良好的注意力会提高我们工作与学习的效率。注意力障碍，主要表现为无法将心理活动指向某一具体事物，或无法将全部精力集中到这一事物上来，同时无法抑制对无关事物的注意。造成这种情况的原因比较复杂，许多较严重的心理障碍都可以引起注意力障碍。而对于学生来说，主要是由于学习负担重，心理压力过大，而造成高度的紧张和焦虑，从而导致了注意力无法集中的障碍。另外，睡眠不足，大脑得不到充分休息，也可能出现注意力涣散的情况。</p>
<p>因此，当你因注意力无法集中而影响学习，倍感苦恼时，不妨采用以下方法来矫治：</p>
<p>(1)、养成良好的睡眠习惯</p>
<p>一些同学因学习负担重，因此，一到晚上便贪黑敖夜，有的同学甚至在宿舍打电筒读书，学到深夜；有的同学不能按时睡眠，在宿舍和同学闲聊等等。结果早晨不能按时起床，即便勉强起来，头脑也是昏沉沉的，一整天都打不起精神，有的甚至在课堂上伏桌睡觉。作为学生，主要的学习任务要在白天完成，白天无精打采，必然效率低下。所以，如果你是“夜猫子”型的，奉劝你学学“百灵鸟”，按时睡觉按时起床，养足精神，提高白天的学习效率。</p>
<p>(2)、学会自我减压</p>
<p>高中学生的学习任务本来就很重，老师、家长的期望，又给同学们心理加上一道法码；一些同学自己对成绩、考试等看得很重，无异是自己给自己加压，必然不堪重负，变得疲惫、紧张和烦躁，心理上难得片刻宁静。因此，我们要学会自我减压，别把成绩的好坏看得太重。一分耕耘，一分收获，只要我们平日努力了，付出了，必然会有好的回报，又何必让忧虑占据心头，去自寻烦恼呢？</p>
<p>(3)、做些放松训练</p>
<p>舒适地坐在椅子上或躺在床上，然后向身体的各部位传递休息的信息。先从左脚开始，使脚部肌肉绷紧，然后松驰，同时暗示它休息，随后命令脚脖子、小腿、膝盖、大腿，一直到躯干部休息，之后，再从脚到躯干，然后从左右手放松到躯干。这时，再从躯干开始到颈部、到头部、脸部全部放松。这种放松训练的技术，需要反复练习才能较好地掌握，而一旦你掌握了这种技术，会使你在短短的几分钟内，达到轻松、平静的状态。</p>
<p>(4)、做些集中注意力的训练</p>
<p>我国年轻的数学家杨乐、张广厚，小时候都曾采用快速做习题的办法，严格训练自己集中注意力。这里给大家介绍一种在心理学中用来锻炼注意力的小游戏。在一张有25个小方格的表中，将1-25的数字打乱顺序，填写在里面，然后以最快的速度从1数到25，要边读边指出，同时计时。</p>
<p>研究表明：7-8岁儿童按顺序导找每张图表上的数字的时间是30-50秒，平均40-42秒；正常成年人看一张图表的时间大约是25-30秒，有些人可以缩短到十几秒。你可以自己多制做几张这样的训练表，每天训练一遍，相信你的注意力水平一定会逐步提高。“培养良好注意品质，提高学生学习成绩”</p>
<p>第二阶段：</p>
<p>注意力的集中作为一种特殊的素质和能力，需要通过训练来获得。那么，训练自己注意力、提高自己专心致志素质的方法有哪些呢？</p>
<p>方法之一：运用积极目标的力量</p>
<p>这种方法的含义是什么？就是当你给自己设定了一个要自觉提高自己注意力和专心能力的目标时，你就会发现，你在非常短的时间内，集中注意力这种能力有了迅速的发展和变化。</p>
<p>同学们要在训练中完成这个进步。要有一个目标，就是从现在开始我比过去善于集中注意力。不论做任何事情，一旦进入，能够迅速地不受干扰。这是非常重要的。比如，你今天如果对自己有这个要求，我要在高度注意力集中的情况下，将这一讲的内容基本上一次都记忆下来。当你有了这样一个训练目标时，你的注意力本身就会高度集中，你就会排除干扰。</p>
<p>同学们知道，在军事上把兵力漫无目的地分散开，被敌人各个围歼，是败军之将。这与我们在学习、工作和事业中一样，将自己的精力漫无目标地散漫一片，永远是一个失败的人物。学会在需要的任何时候将自己的力量集中起来，注意力集中起来，这是一个成功者的天才品质。培养这种品质的第一个方法，是要有这样的目标。</p>
<p>方法之二：培养对专心素质的兴趣</p>
<p>有了这种兴趣，你们就会给自己设置很多训练的科目，训练的方式，训练的手段。你们就会在很短的时间内，甚至完全有可能通过一个暑期的自我训练，发现自己和书上所赞扬的那些大科学家、大思想家、大文学家、大政治家、大军事家一样，有了令人称赞的注意力集中的能力。</p>
<p>同学们在休息和玩耍中可以散漫自在，一旦开始做一件事情，如何迅速集中自己的注意力，这是一个才能。就像一个军事家迅速集中自己的兵力，在一个点上歼灭敌人，这是军事天才。我们知道，在军事上，要集中自己的兵力而不被敌人觉察，要战胜各种空间、地理、时间的困难，要战胜军队的疲劳状态，要调动方方面面的因素，需要各种集中兵力的具体手段。同学们集中自己的精力，注意力，也要掌握各种各样的手段。这些都值得探讨，是很有兴趣的事情。</p>
<p>方法之三：要有对专心素质的自信</p>
<p>千万不要受自己和他人的不良暗示。有的家长从小就这样说孩子：我的孩子注意力不集中。在很多场合都听到家长说：我的孩子上课时精力不集中。有的同学自己可能也这样认为。不要这样认为，因为这种状态可以改变。</p>
<p>如果你现在比较善于集中注意力，那么，肯定那些天才的科学家、思想家、事业家、艺术家在这方面还有值得你学习的地方，你还有不及他们的差距，你就要想办法超过他们。</p>
<p>对于绝大多数同学，只要你有这个自信心，相信自己可以具备迅速提高注意力集中的能力，能够掌握专心这样一种方法，你就能具备这种素质。我们都是正常人、健康人，只要我们下定决心，不受干扰，排除干扰，我们肯定可以做到高度的注意力集中。希望同学们对自己实行训练。经过这样的训练，能够发生一个飞跃。</p>
<p>方法之四：善于排除外界干扰</p>
<p>要在排除干扰中训练排除干扰的能力。毛泽东在年轻的时候为了训练自己注意力集中的能力，曾经给自己立下这样一个训练科目，到城门洞里、车水马龙之处读书。为了什么？就是为了训练自己的抗干扰能力。同学们一定知道，一些优秀的军事家在炮火连天的情况下，依然能够非常沉静地、注意力高度集中地在指挥中心判断战略战术的选择和取向。生死的危险就悬在头上，可是还要能够排除这种威胁对你的干扰，来判断军事上如何部署。这种抗拒环境干扰的能力，需要训练。</p>
<p>我在你们这么大的年纪时曾有意做过这种训练。就是不管环境多么嘈杂，当我进入我要阅读和学习的科目时，对周围的一切因素置若罔闻。这是可以训练成功的。</p>
<p>方法之五：善于排除内心的干扰</p>
<p>在这里要排除的不是环境的干扰，而是内心的干扰。环境可能很安静，在课堂上，周围的同学都坐得很好，但是，自己内心可能有一种骚动，有一种干扰自己的情绪活动，有一种与这个学习不相关的兴奋。对各种各样的情绪活动，要善于将它们放下来，予以排除。这时候，同学们要学会将自己的身体坐端正，将身体放松下来，将整个面部表情放松下来，也就是将内心各种情绪的干扰随同这个身体的放松都放到一边。常常内心的干扰比环境的干扰更严重。</p>
<p>同学们可以想一下，在课堂上，为什么有的同学能够始终注意力集中呢？为什么有的同学注意力不能集中呢？除了有没有学习的目标、兴趣和自信之外，还有一个就是善于不善于排除自己内心的干扰。有的时候并不是周围的同学在骚扰你，而是你自己心头有各种各样浮光掠影的东西。要去除它们，这个能力是要训练的。如果你就是想浑浑噩噩、糊糊涂涂、庸庸俗俗过一生，乃至到了三十岁还要靠父母养活，或者你就是想混世一生，那你可以不训练这个。但是，如果你确实想做一个自己也很满意的现代人，就要具备这种事到临头能够集中自己注意力的素质和能力，善于在各种环境中不但能够排除环境的干扰，同时能够排除自己内心的干扰。</p>
<p>方法之六：节奏分明的处理学习与休息的关系</p>
<p>同学们千万不要这样学习：我这一天就是复习功课，然后，从早晨开始就好像在复习功课，书一直在手边，但是效率很低，同时一会儿干干这个，一会儿干干那个。十二个小时就这样过去了，休息也没有休息好，玩也没玩好，学习也没有什么成效。或者，你一大早到公园念外语，坐了一个小时或两个小时，散散漫漫，说念也念了，说不念也跟没念差不多，没有记住多少东西。这叫学习和休息、劳和逸的节奏不分明。正确的态度是要分明。那就是我从现在开始，集中一小时的精力，比如背诵80个英语单词，看我能不能背诵下来。高度地集中注意力，尝试着一定把这些单词记下来。学习完了，再休息，再玩耍。当需要再次进入学习的时候，又能高度集中注意力。这叫张弛有道。一定要训练这个能力。永远不要熬时间，永远不要折磨自己。一定要善于在短时间内一下把注意力集中，高效率地学习。要这样训练自己：安静的时候，像一棵树；行动的时候，像闪电雷霆；休息的时候，流水一样散漫；学习的时候，却像军事上实施进攻一样集中优势兵力。这样的训练才能使自己越来越具备注意力集中的能力。</p>
<p>方法之七：空间清静</p>
<p>这个方法，非常简单，当你在家中复习功课或学习时，要将书桌上与你此时学习内容无关的其他书籍、物品全部清走。在你的视野中，只有你现在要学习的科目。这种空间上的处理，是你训练自己注意力集中的最初阶段的一个必要手段。同学们常常会发现这样生动的场面，你坐在桌子前，想学数学了，这儿有一张报纸，本来是垫在书底下的，上面有些新闻，你止不住就看开了，看了半天，才知道我是来学数学的。一张报纸就把你牵挂走了。或者本来你是要学习的，桌子一角的小电视还开着呢，看着看着，从数学王国出去了，到了张学友那儿了。这是完全可能的。甚至可能是一个小纸片，上面写着什么字，看着看着又想起一件事情。</p>
<p>所以，作为训练自己注意力的最初阶段，做一件事情之前，首先要清除书桌上全部无关的东西。然后，使自己迅速进入主题。如果你能够做到一分钟之内没有杂念，进入主题，你就了不起。如果你半分钟就能进入主题，就更了不起。如果你一坐在那里，十秒、五秒，当下就进入，那就是天才，那就是效率。有的人说，自己复习功课用了四个小时，其实那四个小时大多数在散漫中、低效率中度过，没有用。反之，你开始学习，一坐在那里，与此无关的全部内容置之脑外，这就是高效率。</p>
<p>方法之八：清理大脑</p>
<p>收拾书桌是为了用视野中的清理集中自己的注意力，那么，你同时也可以清理自己的大脑。你经常收拾书桌，慢慢就会有一个形象的类比，觉得自己的大脑也像一个书桌一样。</p>
<p>大脑是一个屏幕，那里面也堆放着很多东西，一上来，将在自己心头此时此刻浮光掠影活动的各种无关的情绪、思绪和信息收掉，在大脑中就留下你现在要进行的科目，就像收拾你的桌子一样。</p>
<p>同学们，这样的训练希望你们从今天开始就要做，它并不困难。当你将思想中的所有杂念都去除的时候，一瞬间你就进入了专一的主题，你的大脑就充分调动起来，你才有才智，你才有发明，你才有创造，你才有观察的能力、记忆的能力、逻辑推理的能力和想象的能力。如果不是这样，你坐在那里，十分钟之内脑袋瓜里还是车水马龙，还是风马牛不相及，还是天南海北，那么这十分钟是被浪费掉的。再有十分钟，不是车水马龙了，但依然是熙熙攘攘的街道，又十分钟过去了。到最后学习开始了，难免三心二意，效率很低。这种状态我们以后不能再要了，要善于迅速进入自己专心的主题。</p>
<p>方法之九：对感官的全部训练</p>
<p>我们讲了清理自己的书桌，其实更广义说，我们可以进行视觉、听觉、感觉方方面面的类似训练。同学们可以训练自己在视觉中一个时间内盯视一个目标，而不被其他的图像所转移。你们可以训练在一段时间内虽然有万千种声音，但是你们集中聆听一种声音。你们也可以在整个世界中只感觉太阳的存在或者只感觉月亮的存在，或者只感觉周围空气的温度。这种感觉上的专心训练是进行注意力训练的有用的技术手段。</p>
<p>方法之十：不在难点上停留</p>
<p>同学们都会意识到，我们理解的事物、有兴趣的事物，当我们去探究它、观察它时，就比较容易集中注意力。比如说我喜欢数学，数学课就比较容易集中注意力，因为我理解，又比较有兴趣。反之，因为我不太喜欢化学，缺乏兴趣，对老师讲的课又缺乏足够的理解，就有可能注意力分散。</p>
<p>在这种情况下，我们就有了正反两个方面的对策。正的对策是，我们要利用自己的理解力、利用自己的兴趣集中自己的注意力。而对那些自己还缺乏理解、缺乏兴趣的事物，当我们必须研究它、学习它时，这就是一个特别艰难的训练了。</p>
<p>首先，同学们听老师讲课的过程中，出现任何不理解的环节，你不要在这个环节上停留。这一点不懂，没关系，接着听老师往下讲课。你在研究一个事物的时候，这个问题你不太理解，不要紧，你接着往下研究。你读一本书的时候，这个点不太理解，你做了努力还不太理解，没关系，放下来，接着往下阅读。千万不要被前几页的难点挡住，对整本书望而止步。实际上，在你往下阅读的过程中可能会发现，后边大部分内容你都能理解。前边这几页你所谓不理解的东西，你慢慢也会理解。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=315</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>向阳花</title>
		<link>http://www.mvsay.com/?p=312</link>
		<comments>http://www.mvsay.com/?p=312#comments</comments>
		<pubDate>Mon, 28 Mar 2011 05:50:53 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[IamV]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[社会]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=312</guid>
		<description><![CDATA[关于向日葵，曾有一个凄美的希腊神话传说。克吕提厄（Clytie）是一位海洋女神。她曾是太阳神赫利俄斯（Helius）的情人，但后来赫利俄斯又爱上波斯（Persia）公主琉科托厄（Leucothoe）。妒火中烧的克吕提厄向波斯王俄耳卡摩斯（Orchamus）告发了琉科托厄与赫利俄斯的关系。俄耳卡摩斯下令将不贞的女儿活埋。赫利俄斯得知此事后，彻底断绝了与克吕提厄的来往。痴情的克吕提厄一连数天不吃不喝，凝望着赫利俄斯驾驶太阳车东升西落，日渐憔悴，最终化为一株向阳花（向日葵）。 
]]></description>
			<content:encoded><![CDATA[<div class="content">听了首歌 谢天笑的 向阳花.就查了查这个人和花&#8230;向日葵么~~~~<br /> 有兴趣的可以查查这个人 谢天笑<br /> <embed height="400" type="application/x-shockwave-flash" align="middle" width="480" src="http://player.youku.com/player.php/sid/XMTIwNDgyMTA4/v.swf" allowscriptaccess="sameDomain" quality="high"/></div>
<p> 向日葵的花语是沉默的爱 传说一 关于向日葵，曾有一个凄美的希腊神话传说。克吕提厄（Clytie）是一位海洋女神。她曾是太阳神赫利俄斯（Helius）的情人，但后来赫利俄斯又爱上波斯（Persia）公主琉科托厄（Leucothoe）。妒火中烧的克吕提厄向波斯王俄耳卡摩斯（Orchamus）告发了琉科托厄与赫利俄斯的关系。俄耳卡摩斯下令将不贞的女儿活埋。赫利俄斯得知此事后，彻底断绝了与克吕提厄的来往。痴情的克吕提厄一连数天不吃不喝，凝望着赫利俄斯驾驶太阳车东升西落，日渐憔悴，最终化为一株向阳花（向日葵）。</p>
<p>传说二 向日葵&#8211;俄罗斯国花。前苏联人民热爱向日葵，并将它定为国花。现在俄罗斯把国花仍定为向日葵“更无柳絮因风起，惟有葵花向日倾”。向日葵，向往光明之花，合人带来美好希望之花，它全身是宝，把自己无私地奉献给人类。关于向日葵，历史上有一美妙传说。古代有一位农夫女儿名叫明姑，她憨厚老实，长得俊俏，却被后娘“女霸王”视为眼中钉，受到百般凌辱虐待。一次，因一件小事，顶撞了后娘一句，惹怒了后娘，使用皮鞭抽打她，可一下失手打到了前来劝解的亲生女儿身上，这时后娘又气又恨，夜里趁明姑娘熟睡之际挖掉了她的眼睛。明姑疼痛难忍，破门出逃，不久死去，死后在她坟上开着一盘鲜丽的黄花，终日面向阳光，它就是向日葵。表示明姑向往光明，厌恶黑暗之意，这传说激励人们痛恨暴、黑暗，追求光明。这向日葵便繁衍至今。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=312</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expression&lt;Func&lt;int, bool&gt;&gt;与&lt;Func&lt;int, bool&gt;</title>
		<link>http://www.mvsay.com/?p=309</link>
		<comments>http://www.mvsay.com/?p=309#comments</comments>
		<pubDate>Fri, 25 Mar 2011 02:28:02 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[IamV]]></category>
		<category><![CDATA[Dev]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=309</guid>
		<description><![CDATA[Expression&#60;Func&#60;int, bool&#62;&#62;是表达式， &#60;Func&#60;int, bool&#62;是委派(delegate) Expression编译后就会变成delegate，才能运行。 比如 Expression&#60;Func&#60;int, bool&#62;&#62; ex = x=&#62;x &#60; 100; x=&#62;x &#60; 100&#160;&#160;&#160; &#8212;&#62; x是输入参数 int类型,x&#60;100是函数体,返回bool类型 Func&#60;int, bool&#62; func = ex.Compile(); 然后你就可以调用func： func(5) //-返回 true func(200) //- 返回 false 而表达式是不能直接调用的。 var articles = context.Employees.OrderBy(p=&#62;p.EmployeeName).Skip(startRecord).Take(pageSize);]]></description>
			<content:encoded><![CDATA[<p>Expression&lt;Func&lt;int, bool&gt;&gt;是表达式，<br /> &lt;Func&lt;int, bool&gt;是委派(delegate)<br /> Expression编译后就会变成delegate，才能运行。<br /> 比如 Expression&lt;Func&lt;int, bool&gt;&gt; ex = <font style="BACKGROUND-COLOR: #ff0000" color="#000000">x=&gt;x &lt; 100</font>;<br /> x=&gt;x &lt; 100&nbsp;&nbsp;&nbsp; &#8212;&gt; x是输入参数 int类型,x&lt;100是函数体,返回bool类型<br /> Func&lt;int, bool&gt; func = ex.Compile();<br /> 然后你就可以调用func：<br /> func(5) //-返回 true<br /> func(200) //- 返回 false<br /> 而表达式是不能直接调用的。</p>
<p>var articles = context.Employees.OrderBy(p=&gt;p.EmployeeName).Skip(startRecord).Take(pageSize);</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=309</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RJ45水晶头的正确接线方法</title>
		<link>http://www.mvsay.com/?p=298</link>
		<comments>http://www.mvsay.com/?p=298#comments</comments>
		<pubDate>Wed, 16 Feb 2011 07:41:29 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[学习]]></category>
		<category><![CDATA[网线]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=298</guid>
		<description><![CDATA[网线应该是两头都要做RJ45头的。有两种接线方法，一种是平行线（也叫直连线）一种是交叉线。所谓的平行线（又叫直连线）实际上就是线的两头采用同样的做法——要么两头都用T568A来做，要么两头都用T568B来做。而交叉线就是一头T568A而另外一头就用T568B——也就是两头不一样的做法。

　　平行线（又叫直连线）一般使用较多的标准是T568B，在使用三类双绞线、五类双绞线、增强的五类双绞线的网络工程中一般遵循T568B的接线标准，在使用五类双绞线时，其传输速率可达到100Mbps。

　 应 用 类 别 接线方法：

　 计算机——计算机： 交叉线 

　 计算机——交换机： 平行线 

　 交换机——交换机： 交叉线或者平行线 

]]></description>
			<content:encoded><![CDATA[<table style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="100%">
<div style="MARGIN: 15px" id="art" width="100%"><span lang="EN-US" xml:lang="EN-US">1</span><span style="FONT-FAMILY: 宋体">．</span><span lang="EN-US" xml:lang="EN-US">Ethernet</span><span style="FONT-FAMILY: 宋体">简介</span>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> IEEE 802</span><span style="FONT-FAMILY: 宋体">标准给出了局域网</span><span lang="EN-US" xml:lang="EN-US">(LAN)</span><span style="FONT-FAMILY: 宋体">的标准化参考模型，它只对应于</span><span lang="EN-US" xml:lang="EN-US">OSI</span><span style="FONT-FAMILY: 宋体">参考模型中的数据链路层与物理层，并将数据链路层划分为逻辑链路控制（</span><span lang="EN-US" xml:lang="EN-US">LLC</span><span style="FONT-FAMILY: 宋体">）子层与介质访问控制（</span><span lang="EN-US" xml:lang="EN-US">MAC</span><span style="FONT-FAMILY: 宋体">）子层。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">其中，</span><span lang="EN-US" xml:lang="EN-US">IEEE 802.3</span><span style="FONT-FAMILY: 宋体">标准定义了</span><span lang="EN-US" xml:lang="EN-US">CSMA/CD</span><span style="FONT-FAMILY: 宋体">总线介质访问控制子层与物理层规范，这也就是</span><span lang="EN-US" xml:lang="EN-US">Ethernet</span><span style="FONT-FAMILY: 宋体">（以太网）局域网的标准。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">构成</span><span lang="EN-US" xml:lang="EN-US">Ethernet</span><span style="FONT-FAMILY: 宋体">网络<strong><em>连接</em></strong>的两个要素是以太网卡（带收发器）和传输介质（连接电缆）。</span></p>
<p class="MsoNormal">
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US">2</span><span style="FONT-FAMILY: 宋体">．传输介质</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">最常用的传输介质为双绞线，又分为屏蔽双绞线（</span><span lang="EN-US" xml:lang="EN-US">shielded twisted pair, STP</span><span style="FONT-FAMILY: 宋体">）和非屏蔽双绞线（</span><span lang="EN-US" xml:lang="EN-US">unshielded twisted pair, UTP</span><span style="FONT-FAMILY: 宋体">）两种。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">根据传输特性，又可分为三类、五类、超五类和六类、七类等，如下表。</span></p>
<table style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; BORDER-COLLAPSE: collapse; BORDER-TOP: medium none; BORDER-RIGHT: medium none" class="MsoTableGrid" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">Cable Category</span></p>
</td>
<td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">Rated Frequency Bandwidth (MHz)</span></p>
</td>
<td style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">Common Uses</span></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">1</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">None</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">2</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">1</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">Telephone Wiring</span></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">3</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">16</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">Telephone Wiring, 10Base-T</span></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">4</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">20</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">Token-Ring, 10Base-T</span></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">5</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">100</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">100Base-TX, 10Base-T</span></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">5e</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">100</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">1000Base-T, 100Base-TX, 10Base-T</span></p>
</td>
</tr>
<tr>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: 1pt solid; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 86.4pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="115">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">6</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 171pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="228">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">250</span></p>
</td>
<td style="BORDER-BOTTOM: 1pt solid; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; WIDTH: 168.7pt; PADDING-RIGHT: 5.4pt; BORDER-TOP: medium none; BORDER-RIGHT: 1pt solid; PADDING-TOP: 0cm" valign="top" width="225">
<p style="TEXT-ALIGN: center" class="MsoNormal" align="center"><span lang="EN-US" xml:lang="EN-US">1000Base-T, 100Base-TX, 10Base-T</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> *</span><span style="FONT-FAMILY: 宋体">更详细资料可以参考</span><span lang="EN-US" xml:lang="EN-US">[3][6]</span><span style="FONT-FAMILY: 宋体">或其他资源。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">目前我们最常用的是五类非屏蔽双绞线，由于信号在传输介质中的衰减，因此，五类非屏蔽双绞线的长度不可超过</span> <span lang="EN-US" xml:lang="EN-US">100</span><span style="FONT-FAMILY: 宋体">米</span><span style="FONT-FAMILY: 宋体">。</span></p>
<p class="MsoNormal">
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US">3</span><span style="FONT-FAMILY: 宋体">．</span><span lang="EN-US" xml:lang="EN-US">RJ-45</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> EIA/TIA</span><span style="FONT-FAMILY: 宋体">（</span><span lang="EN-US" xml:lang="EN-US">Electronic Industries Association/Telecommunications Industry Association</span><span style="FONT-FAMILY: 宋体">）指定非屏蔽双绞线使用</span><span lang="EN-US" xml:lang="EN-US">RJ-45</span><span style="FONT-FAMILY: 宋体">接口</span><span lang="EN-US" xml:lang="EN-US">(ISO8877)</span><span style="FONT-FAMILY: 宋体">。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> RJ</span><span style="FONT-FAMILY: 宋体">（</span><span lang="EN-US" xml:lang="EN-US">registered jack</span><span style="FONT-FAMILY: 宋体">）是电话或计算机网络设备等电信设备的标准物理接口。</span></p>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/5043A91A8C518E0460733A87C91C89BC3E7BB0A3.gif" width="159" height="116"/></div>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">上图是</span><span lang="EN-US" xml:lang="EN-US">RJ-45</span><span style="FONT-FAMILY: 宋体">的插头与插孔示意图。双绞线中有</span><span lang="EN-US" xml:lang="EN-US">4</span><span style="FONT-FAMILY: 宋体">对导线，因此接口也相应的有</span><span lang="EN-US" xml:lang="EN-US">1</span><span style="FONT-FAMILY: 宋体">～</span><span lang="EN-US" xml:lang="EN-US">8</span><span style="FONT-FAMILY: 宋体">号引脚。注意在讨论接线顺序以及与信号的对应关系时，总是以引脚标号为准，母口与公口相连接时，也总是使标号一一对应。</span></p>
<p class="MsoNormal">
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US">4</span><span style="FONT-FAMILY: 宋体">．接线方法</span></p>
<p style="TEXT-INDENT: 2em"><span style="FONT-FAMILY: 宋体">T568A的排线顺序为：<strong>绿白</strong>、<strong>绿</strong>、<strong>橙白</strong>、蓝、蓝白、<strong>橙</strong>、棕白、棕。</span></p>
<p style="TEXT-INDENT: 2em"><span style="FONT-FAMILY: 宋体">T568B的排线顺序为：<strong>橙白</strong>、<strong>橙</strong>、<strong>绿白</strong>、蓝、蓝白、<strong>绿</strong>、棕白、棕。</span></p>
<p style="TEXT-INDENT: 2em"><span style="FONT-FAMILY: 宋体"><strong>实际使用的-&gt;1/2/3/6</strong> 也就是<strong>绿对</strong>和<strong>橙对</strong></span></p>
<p class="MsoNormal">网线应该是两头都要做RJ45头的。有两种接线方法，一种是平行线（也叫直连线）一种是交叉线。所谓的平行线（又叫直连线）实际上就是线的两头采用同样的做法——要么两头都用T568A来做，要么两头都用T568B来做。而交叉线就是一头T568A而另外一头就用T568B——也就是两头不一样的做法。</p>
<p style="TEXT-INDENT: 2em">　　平行线（又叫直连线）一般使用较多的标准是T568B，在使用三类双绞线、五类双绞线、增强的五类双绞线的网络工程中一般遵循T568B的接线标准，在使用五类双绞线时，其传输速率可达到100Mbps。</p>
<p style="TEXT-INDENT: 2em"><strong>　 <em>应 用 类 别 接线方法：</em></strong></p>
<p style="TEXT-INDENT: 2em"><em><strong>　 计算机——计算机： 交叉线</strong></em></p>
<p style="TEXT-INDENT: 2em"><em><strong>　 计算机——交换机： 平行线</strong></em></p>
<p style="TEXT-INDENT: 2em"><em><strong>　 交换机——交换机： 交叉线或者平行线</strong></em></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">（</span><span lang="EN-US" xml:lang="EN-US">1</span><span style="FONT-FAMILY: 宋体">）双绞线的示意图如下：</span></p>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/8996C2E0A19CA4B41D9196E4487C0599EF827448.jpg" width="240" height="141"/></div>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/FEB0C4872232EB0AE029D0F25773527862C58D49.gif" width="348" height="111"/></div>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">（</span><span lang="EN-US" xml:lang="EN-US">2</span><span style="FONT-FAMILY: 宋体">）双绞线与水晶头</span><span lang="EN-US" xml:lang="EN-US">(RJ-45</span><span style="FONT-FAMILY: 宋体">公口</span><span lang="EN-US" xml:lang="EN-US">)</span><span style="FONT-FAMILY: 宋体">的连接方法有两种标准，一是</span><span lang="EN-US" xml:lang="EN-US">T-568B</span><span style="FONT-FAMILY: 宋体">（常用），二是</span><span lang="EN-US" xml:lang="EN-US">T-568A</span><span style="FONT-FAMILY: 宋体">，如下图：</span></p>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/B5723D9BF7C972C7603DC084C0626ED43E7EB94F.gif" width="447" height="649"/></div>
<p class="MsoNormal">
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">（</span><span lang="EN-US" xml:lang="EN-US">3</span><span style="FONT-FAMILY: 宋体">）平行线（</span><span lang="EN-US" xml:lang="EN-US">Straight through cable</span><span style="FONT-FAMILY: 宋体">）与交叉线（</span><span lang="EN-US" xml:lang="EN-US">Crossover cable</span><span style="FONT-FAMILY: 宋体">）</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">由于存在以上两种标准，一根双绞线的两头都可以采取任一标准与</span><span lang="EN-US" xml:lang="EN-US">RJ-45</span><span style="FONT-FAMILY: 宋体">水晶头进行连接，于是出现了平行线与交叉线的差别。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">平行线是指双绞线的两头采取同一标准（通常是</span><span lang="EN-US" xml:lang="EN-US">T-568B</span><span style="FONT-FAMILY: 宋体">）与水晶头进行连接，内部不交叉的接线方法。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">交叉线则是指双绞线的两头采取不同标准（一端采用</span><span lang="EN-US" xml:lang="EN-US">T-568B</span><span style="FONT-FAMILY: 宋体">，另一端采用</span><span lang="EN-US" xml:lang="EN-US">T-568A</span><span style="FONT-FAMILY: 宋体">）与水晶头进行连接，</span><span lang="EN-US" xml:lang="EN-US">4</span><span style="FONT-FAMILY: 宋体">对线在内部都要交叉（包括不使用的蓝对和棕对），如下表：</span></p>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/62F8E42F1B958BF69DE57D04F80D7B2EDDC161C3.jpg" width="770" height="259"/><br /> 
<div style="TEXT-ALIGN: left">
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">平行线与交叉线用于不同场合和不同通信设备的互连，关键是要通过双绞线将互连的两个设备的</span><span lang="EN-US" xml:lang="EN-US">Transmit+</span><span style="FONT-FAMILY: 宋体">与</span><span lang="EN-US" xml:lang="EN-US">Receive+</span><span style="FONT-FAMILY: 宋体">连通，</span><span lang="EN-US" xml:lang="EN-US">Transmit</span><span style="FONT-FAMILY: 宋体">－与</span><span lang="EN-US" xml:lang="EN-US">Receive</span><span style="FONT-FAMILY: 宋体">－连通，这样两个设备才能正常地进行网络通信。</span></p>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">一般而言，平行线用于连接到</span><span lang="EN-US" xml:lang="EN-US">Hub</span><span style="FONT-FAMILY: 宋体">或</span><span lang="EN-US" xml:lang="EN-US">Switch</span><span style="FONT-FAMILY: 宋体">，交叉线则用于对等的两个通信设备的直连，这是因为对等的通信设备的接口定义通常采用同一标准，一个简单的例子是，假设计算机以太网卡的</span><span lang="EN-US" xml:lang="EN-US">Transmit</span><span style="FONT-FAMILY: 宋体">和</span><span lang="EN-US" xml:lang="EN-US">Receive</span><span style="FONT-FAMILY: 宋体">信号与</span><span lang="EN-US" xml:lang="EN-US">RJ-45</span><span style="FONT-FAMILY: 宋体">引脚的对应关系如下：</span></p>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/2C0DD934F09D42BC45CFA9086B46345BA6EC8264.jpg" width="244" height="426"/></div>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">那么两台计算机如果使用一根双绞线进行直连通信，则需要采用交叉线，如下图所示：</span></p>
<div style="TEXT-ALIGN: center"><img border="0" src="http://www.mvsay.com/wp-content/uploads/2011/02/BC9F236DD09CFD8E843F1DA812DE8B0AD16A76A0.jpg" width="360" height="347"/></div>
<p class="MsoNormal"><span lang="EN-US" xml:lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span> <span style="FONT-FAMILY: 宋体">有的网卡接口电路设计为可以根据需要自动对双绞线进行交叉或非交叉处理，这时采用平行线或交叉线都可以。</span></p>
</p></div>
</p></div>
</p></div>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=298</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HttpContext, HttpModules 和 HttpHandlers</title>
		<link>http://www.mvsay.com/?p=296</link>
		<comments>http://www.mvsay.com/?p=296#comments</comments>
		<pubDate>Thu, 20 Jan 2011 06:15:27 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[学习]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=296</guid>
		<description><![CDATA[摘自网络的一些
HttpContext, HttpModules 和 HttpHandlers 的介绍]]></description>
			<content:encoded><![CDATA[<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><a href="http://blog.csdn.net/quanke1981/archive/2007/06/13/1650419.aspx">http://blog.csdn.net/quanke1981/archive/2007/06/13/1650419.aspx</a></span></p>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span">httpApplication它本身对发送给应用程序的数据一无所知-它只是一个通过事件来通讯的消息对象.它触发事件并通过HttpContext对象来向被调用函数传递消息.实际的当前请求的状态数据由前面提到的HttpContext对象维护.它提供了所有请求专有的数据并从进入管道开始到结束一直跟随请求.图7显示了ASP.NET管道中的流程.注意上下文对象(即HttpContext),这个从请求开始到结束一直都是你”朋友”的对象,可以在一个事件处理函数中保存信息并在以后的事件处理函数中取出.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　一旦管道被启动,HttpApplication开始象图六那样一个个的触发事件.每个事件处理器被触发,如果事件被挂接,这些处理器将执行它们自己的任务.这个处理的主要任务是最终调用挂接到此特定请求的HttpHandler.处理器(handler)是ASP.NET请求的核心处理机制,通常也是所有应用程序级别的代码被执行的地方.记住ASP.NET页面和Web服务框架都是作为HttpHandler实现,这里也是处理请求的的核心之处.模块(module)趋向于成为一个传递给处理器(handler)的上下文的预处理或后处理器.ASP.NET中典型的默认处理器包括预处理的认证,缓存以及后处理中各种不同的编码机制.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　有很多关于HttpHandler和HttpModule的可用信息,所以为了保持这篇文章在一个合理的长度,我将提供一个关于处理器的概要介绍.</span></p>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><strong>HttpModule<span class="Apple-converted-space">&nbsp;</span><br /></strong>&nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　当请求在管道中传递时,HttpApplicaion对象中一系列的事件被触发.我们已经看到这些事件在Global.asax中作为事件被发布.这种方法是特定于应用程序的,可能并不总是你想要的.如果你要建立一个通用的可用被插入任何Web应用程序的HttpApplication事件钩子,你可用使用HttpModule,这是可复用的,不需要特定语应用程序代码的,只需要web.config中的一个条目.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　模块本质上是过滤器(fliter)-功能上类似于ISAPI过滤器,但是它工作在ASP.NET请求级别上.模块允许为每个通过HttpApplication对象的请求挂接事件.这些模块作为外部程序集中的类存贮.,在web.config文件中被配置,在应用程序启动时被载入.通过实现特定的接口和方法,模块被挂接到HttpApplication事件链上.多个HttpModule可用被挂接在相同的事件上,事件处理的顺序取决于它们在Web.config中声明的顺序.下面是在Web.config中处理器定义.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜configuration＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜system.web＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜httpModules＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜add name= &#8220;BasicAuthModule&#8221;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;type=&#8221;HttpHandlers.BasicAuth,WebStore&#8221; /＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜/httpModules＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜/system.web＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;＜/configuration＞<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　注意你需要指定完整的类型名和不带dll扩展名的程序集名.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　模块允许你查看每个收到的Web请求并基于被触发的事件执行一个动作.模块在修改请求和响应数据方面做的非常优秀,可用为特定的程序提供自定义认证或者为发生在ASP.NET中的每个请求增加其他预处理/后处理功能.许多ASP.NET的功能,像认证和会话(Session)引擎都是作为HttpModule来实现的.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　虽然HttpModule看上去很像ISAPI过滤器,它们都检查每个通过ASP.NET应用的请求,但是它们只检查映射到单个特定的ASP.NET应用或虚拟目录的请求,也就是只能检查映射到ASP.NET的请求.这样你可以检查所有ASPX页面或者其他任何映射到ASP.NET的扩展名.你不能检查标准的.HTM或者图片文件,除非你显式的映射这些扩展名到ASP.NET ISAPI dll上,就像图1中展示的那样.一个常见的此类应用可能是使用模块来过滤特定目录中的JPG图像内容并在最上层通过GDI+来绘制’样品’字样.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　实现一个HTTP模块是非常简单的:你必须实现之包含两个函数(Init()和Dispose())的IHttpModule接口.传进来的事件参数中包含指向HTTPApplication对象的引用,这给了你访问HttpContext对象的能力.在这些方法上你可以挂接到HttpApplication事件上.例如,如果你想挂接AuthenticateRequest事件到一个模块上,你只需像列表5中展示的那样做<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　列表5:基础的HTTP模块是非常容易实现的<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;public class BasicAuthCustomModule : IHttpModule<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;{<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　public void Init(HttpApplication application)<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　{<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　// *** Hook up any HttpApplication events<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　application.AuthenticateRequest += new EventHandler(this.OnAuthenticateRequest);<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　}<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　public void Dispose() { }<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　public void OnAuthenticateRequest(object source, EventArgs eventArgs)<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　{<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　HttpApplication app = (HttpApplication) source;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　HttpContext Context = HttpContext.Current;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　… do what you have to do… }<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　}<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　记住你的模块访问了HttpContext对象,从这里可以访问到其他ASP.NET管道中固有的对象,如请求(Request)和响应(Response),这样你还可以接收用户输入的信息等等.但是记住有些东西可能是不能访问的,它们只有在处理链的后段才能被访问.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　你可以在Init()方法中挂接多个事件,这样你可以在一个模块中实现多个不同的功能.然而,将不同的逻辑分到单独的类中可能会更清楚的将模块进行模块化(译注:这里的模块化和前面的模块没有什么关系)在很多情况下你实现的功能可能需要你挂接多个事件-例如一个日志过滤器可能在BeginRequest事件中记录请求开始时间,然后在EndRequest事件中将请求结束写入到日志中.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　注意一个HttoModule和HttpApplication事件中的重点:Response.End()或HttpApplication.CompleteRequest()会在HttpApplication和Module的事件链中”抄近道”.看”注意Response.End()”来获得更多信息.<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　注意Response.End()<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;<span class="Apple-converted-space">&nbsp;</span><br /> &nbsp;&nbsp;　　当创建HttpModule或者在Global.asax中实现事件钩子的时候,当你调用Response.End或 Appplication.CompleteRequest的时候要特别注意.这两个函数都结束当前请求并停止触发在HTTP管道中后续的事件,然后发生将控制返回到Web服务器中.当你在处理链的后面有诸如记录日志或对内容进行操作的行为时,因为他们没有被触发,有可能使你上当.例如,sample中logging的例子就会失败,因为如果调用Response.End()的话,EndRequest事件并不会被触发</p>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">&nbsp;</p>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">==============================================</p>
<h2 style="BORDER-BOTTOM: rgb(102,102,102) 1px dashed; BACKGROUND-COLOR: rgb(229,238,247); MARGIN-TOP: 15px; PADDING-LEFT: 10px; FONT-SIZE: 1em; BORDER-TOP: rgb(102,102,102) 1px solid"><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><a style="BORDER-BOTTOM: rgb(0,51,153) 1px; PADDING-BOTTOM: 2px; COLOR: rgb(0,0,0); TEXT-DECORATION: none" id="ctl02_TitleUrl" href="http://www.cnblogs.com/ricksun/articles/1545491.html" name="ctl02_TitleUrl">关于HttpHandlers和HttpModules的不同</a></span></h2>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><a href="http://www.cnblogs.com/ricksun/articles/1545491.html">http://www.cnblogs.com/ricksun/articles/1545491.html</a></p>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><span style="LINE-HEIGHT: 25px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 14px" class="Apple-style-span">当 IIS 接收一个请求时，根据 IIS 的设置将扩展映射到一个 ISAPI 筛选器。将 .ASPX、.asmx、.asd 和其他扩展映射到 ASPnet_isapi.dll，该 ASPnet_isapi.dll 只是一种启动 ASP.NET 运行库的 ISAPI 筛选器。一旦请求到达 ASP.NET 运行库，它在 HTTPApplication 对象处启动，该对象担当 ASP.NET Web 应用程序的宿主。HTTPApplication 对象：<br /> 1.<br /> 读取机器级和应用程序级的配置文件。<br /> 2.<br /> 通过一个或多个 HTTPModule 实例传递请求。每个 HTTPModule 提供一种服务，例如会话维护、身份验证，或配置文件维护。这些模块将请求传递回 HTTPApplication。<br /> 3.<br /> 根据谓词和路径将请求传递给 HTTPHandler。谓词指请求中使用的 HTTP 谓词（GET、POST、FTP，等等），而路径指应用程序中的 URL。根据处理程序的配置方式，该请求可能作为一个 ASP.NET 页（System.Web.UI.Page 为 IHTTPHandler 的一种实现）加以处理，或者该请求可能触发另一个操作，例如批编译所有的 Web 页（precomiplation.asd 触发 PrecompHandler）。<br /> 在 ASP.NET 2.0 中，该模型没有变化，但是，添加了几种新模块和处理程序以提供其他的服务。与 ASP.NET 1.x 一样，您可以扩展、替换或重新配置任何模块或处理程序类，以提供自己的自定义功能。<br /> 从这里可以看到，<br /> httpModules只从功能性方面出发来触发事件．<br /> 而httpHandler从访问方式及访问文件后缀来触发事件．<br /> &nbsp;<img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" border="0" alt src="http://images.cnblogs.com/cnblogs_com/ricksun/0293ljsajf0q3j.gif" width="344" height="389"/><span class="Apple-converted-space">&nbsp;</span></p>
<p> <span style="LINE-HEIGHT: 19px; FONT-FAMILY: Verdana; COLOR: rgb(255,255,255); FONT-SIZE: 13px">&nbsp;</span></span></span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="LINE-HEIGHT: 19px; FONT-FAMILY: Verdana; COLOR: rgb(255,255,255); FONT-SIZE: 13px"><span style="COLOR: rgb(0,0,0)">ASP.Net处理Http Request时，使用Pipeline（管道）方式，由各个HttpModule对请求进行处理，然后到达 HttpHandler，HttpHandler处理完之后，仍经过Pipeline中各个HttpModule的处理，最后将HTML发送到客户端浏览 器中。</span></span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">生命周期中涉及到几个非常重要的对象：HttpHandler,HttpModule,IHttpHandlerFactory，他们的执行(顺序)大致的执行过程是这样的：client端发送页面请求，被IIS的某个进程截获，它根据申请的页 面后缀(.aspx)不同，调用不同的页面处理程序(.asp-&gt;asp.dll; .aspx-&gt;ISAPI.dll).而页面处理程序在处理过程中，则要经历HttpModule,HttpHandler的处理：前者</span><font color="#FF0000"><span style="COLOR: rgb(0,0,0)">HttpModule用于页面处理前和处理后的一些事件的处理</span></font><span style="COLOR: rgb(0,0,0)">，</span><font color="#FF0000"><span style="COLOR: rgb(0,0,0)">后者HttpHandler进行真正的页面的处理</span></font><span style="COLOR: rgb(0,0,0)">。</span><br /> <span style="COLOR: rgb(0,0,0)">如前所说，HttpModule会在页面处理前和后对页面进行处理，所以它不会影响真正的页面请求。通常用在给每个页面的头部或者尾部添加一些信息（如版 权声明）等.曾经见过一些免费的空间，我们的页面上传上去后，浏览的时候发现，在每个页面的头部和尾部多了很多小广告&#8230;.,如果理解了 HttpModule的原理，要做这个就不是很难了~</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"> <span style="COLOR: rgb(0,0,0)">IHttpModule与IHttpHandler的区别整理</span><br /> <span style="COLOR: rgb(0,0,0)">1.先后次序.先IHttpModule,后IHttpHandler.</span>&nbsp;<font color="#FF0000"><span style="COLOR: rgb(0,0,0)">注:</span></font><span style="COLOR: rgb(0,0,0)">Module要看你响应了哪个事件，一些事件是在Handler之前运行的，一些是在Handler之后运行的</span><br /> <span style="COLOR: rgb(0,0,0)">2.对请求的处理上:</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;IHttpModule是属于大小通吃类型,无论客户端请求的是什么文件,都会调用到它;例如aspx,rar,html的请求.</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;IHttpHandler则属于挑食类型,只有ASP.net注册过的文件类型(例如aspx,asmx等等)才会轮到调用它.</span><br /> <span style="COLOR: rgb(0,0,0)">3.IHttpHandler按照你的请求 生成响应的内容，IHttpModule对请求进行预处理，如验证、修改、过滤等等，同时也可以对响应进行处理</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px">&nbsp;</p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">ASP.Net系统本身配置有很多HttpHandler和HttpModule，以处理aspx等.Net标准的页面文件，以及这些页面文件中标 准的事件处理等。查看%System%/Microsoft.NET\Framework\v2.0.50727\CONFIG目录下的 web.config文件中的httpHandlers和httpModules节点，可以看到这些配置。如果有兴趣，可以使用Reflector查 看.Net系统中相关的类和方法，了解.Net如何处理以及做了什么处理。</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">.Net也提供了一套机制来开发自定义的HttpHandler和 HttpModule，均可以用于对HttpRequest的截取，完成自定义的处理。 HttpModule 继承System.Web.IHttpModule接口，实现自己的HttpModule类。必须要实现接口的两个方法：Init和Dispose。在 Init中，可以添加需要截取的事件；Dispose用于资源的释放，如果在Init中创建了自己的资源对象，请在Dispose中进行释放。</span></p>
<div style="BORDER-BOTTOM: rgb(204,204,204) 1px solid; BORDER-LEFT: rgb(204,204,204) 1px solid; PADDING-BOTTOM: 5px; OVERFLOW-X: auto; OVERFLOW-Y: auto; BACKGROUND-COLOR: rgb(245,245,245); PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: 'Courier New'; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: rgb(204,204,204) 1px solid; BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-TOP: 5px" class="cnblogs_code"><img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Code_Open_Image_175034" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_175034').style.display='none'; getElementById('Code_Closed_Image_175034').style.display='inline'; getElementById('Code_Closed_Text_175034').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"/><span style="DISPLAY: inline; FONT-FAMILY: 'Courier New'" id="Code_Open_Text_175034"><br /> <span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;1</span><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">namespace</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;MyModule<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;2</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_19_550_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_19_550_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_19_550_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_19_550_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif"/></span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_19_550_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;3</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">class</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;MyHttpModule&nbsp;:&nbsp;IHttpModule<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;4</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_63_548_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_63_548_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_63_548_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_63_548_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_63_548_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;5</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;MyHttpModule()<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;6</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_95_102_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_95_102_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_95_102_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_95_102_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_95_102_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;7</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;8</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;9</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">Init方法用来注册HttpApplication&nbsp;事件。</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">10</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">void</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Init(HttpApplication&nbsp;r_objApplication)<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">11</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_202_285_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_202_285_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_202_285_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_202_285_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_202_285_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">12</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r_objApplication.BeginRequest&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">+=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">new</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;EventHandler(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">this</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">.BeginRequest);<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">13</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">14</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">15</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">void</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Dispose()<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">16</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_321_328_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_321_328_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_321_328_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_321_328_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_321_328_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">17</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">18</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">19</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">private</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">void</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;BeginRequest(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">object</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;r_objSender,&nbsp;EventArgs&nbsp;r_objEventArgs)<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">20</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_414_545_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_414_545_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_414_545_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_414_545_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_414_545_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">21</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpApplication&nbsp;objApp&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;(HttpApplication)r_objSender;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">22</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objApp.Response.Write(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">您请求的URL为</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">+</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;objApp.Request.Path);<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">23</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">24</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">25</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"/>}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">26</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/></span></span></div>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">将编译的dll文件拷贝到web项目的bin目录下，在web项目的web.config文件system.web节点中配置：</span>&nbsp;<br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 这样就将自定义的HttpModule类MyHttpModule插入到了当前web的HttpModule的Pipeline中。</span>&nbsp;<font color="#FF0000"><span style="COLOR: rgb(0,0,0)">HttpModule</span></font><span style="COLOR: rgb(0,0,0)">主要功能是</span><font color="#FF0000"><span style="COLOR: rgb(0,0,0)">对</span></font><span style="COLOR: rgb(0,0,0)">Application的</span><font color="#FF0000"><span style="COLOR: rgb(0,0,0)">各个事件进行截取</span></font><span style="COLOR: rgb(0,0,0)">，在这些事件中完成自己的处理。其实如果自己开发一些项目，直接在</span>&nbsp;<font color="#FF0000"><span style="COLOR: rgb(0,0,0)">Global.asax</span></font><span style="COLOR: rgb(0,0,0)">中处理已经足够了。如果是开发一个Framework或者是某些方面的组件，需要在事件中添加处理，开发自定义的 HttpModule，可以避免使用Framework或者组件时，还得手工在Global.asax中添加代码。&nbsp;&nbsp;&nbsp;&nbsp; 目前想到的开发自定义HttpModule的用途，有全局的身份/权限验证、自定义网站访问/操作日志的记录、处于管理/调试等目的对站点进行监控追踪 等。当然，如果是结合自定义的HttpHandler进行Framework的开发，HttpModule可以用于其它的一些特殊的处理。</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp; &nbsp;&nbsp; &lt;httpModules&gt;</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &lt;add name=&#8221;test&#8221; type=&#8221;MyHttpModuleTest.MyHttpModule,MyHttpModule&#8221;/&gt;</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/httpModules&gt;</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp; 注意要区分大小写，因为web.config作为一个XML文件是大小写敏感的。“type=MyHttpModuleTest.MyHttpModule,MyHttpModule”告诉我们系统将会将http request请求交给位于MyHttpModule.dll文件中的MyHttpModuleTest.MyHttpModule类去处理。HttpHandler是完全的对Http Request的截取。</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 首先，继承System.Web.IHttpHandler接口，实现自己的HttpHandler类。必须要实现接口的ProcessRequest方 法和IsReusable属性。ProcessRequest方法中完成对每个Http Request的处理，发送处理结果的HTML到输出缓存中。IsReusable属性被.Net Framework调用，用以确定这个HttpHandler的实例是否可以被重用于同类型其它的Request处理。</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 如果你在自己的HttpHandler类中，需要读取或者是写Session值，需要再继承一个接口IRequiresSessionState。这个接 口没有任何方法，只是一个标记接口。继承这个接口之后，就可以在自己的HttpHandler中访问Session，可以在Session中写入值。</span></p>
<div style="BORDER-BOTTOM: rgb(204,204,204) 1px solid; BORDER-LEFT: rgb(204,204,204) 1px solid; PADDING-BOTTOM: 5px; OVERFLOW-X: auto; OVERFLOW-Y: auto; BACKGROUND-COLOR: rgb(245,245,245); PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: 'Courier New'; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: rgb(204,204,204) 1px solid; BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-TOP: 5px" class="cnblogs_code"><img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Code_Open_Image_175110" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_175110').style.display='none'; getElementById('Code_Closed_Image_175110').style.display='inline'; getElementById('Code_Closed_Text_175110').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"/><span style="DISPLAY: inline; FONT-FAMILY: 'Courier New'" id="Code_Open_Text_175110"><br /> <span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;1</span><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">namespace</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;MyHandler<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;2</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_20_379_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_20_379_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_20_379_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_20_379_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif"/></span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_20_379_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;3</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">class</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;MyHttpHandler&nbsp;:&nbsp;IHttpHandler,&nbsp;IRequiresSessionState<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;4</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_91_377_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_91_377_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_91_377_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_91_377_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_91_377_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;5</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_120_122_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_120_122_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_120_122_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_120_122_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;MyHttpHandler()&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_120_122_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;6</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">bool</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;IsReusable<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;7</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_154_188_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_154_188_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_154_188_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_154_188_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_154_188_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;8</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_166_182_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_166_182_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_166_182_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_166_182_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">get</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_166_182_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">return</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">true</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;9</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">10</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">void</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;ProcessRequest(HttpContext&nbsp;context)<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">11</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_245_373_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_245_373_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_245_373_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_245_373_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_245_373_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">12</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpResponse&nbsp;objResponse&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;context.Response&nbsp;;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">13</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objResponse.Write(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">This&nbsp;request&nbsp;is&nbsp;handled&nbsp;by&nbsp;MyHttpHandler</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">);<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">14</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">15</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>&nbsp;&nbsp;}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">16</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"/>}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">17</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">18</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/></span></span></div>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px">把编译的dll文件拷贝到web项目的bin目录下。<br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 接下来，这样来测试一下MyHttpHandler。我们为IIS配置一个以.cc为后缀名的文件类型，用我们写的MyHttpHandler来处理。</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 首先，在IIS站点的Configuration配置里面，添加一个对.cc后缀名处理的Application Extention Mapping项。&nbsp;&nbsp;</span>&nbsp;<br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 然后，在web项目的web.config节点节点中配置：</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">MyHttpHandler, MyHandler&#8221;/&gt;</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; verb属性配置这个HttpHandler处理那些HTTP方法，例如GET、POST等，如果是处理所有方法，就用*。path属性配置HttpHandler对哪些文件进行处理，例如可以是myfile.cc，如果是处理所有的.cc文件，就用*.cc。</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 这样，这个站点上所有.cc类型文件的访问，都由MyHttpHandler处理。使用</span><a style="BORDER-BOTTOM: rgb(0,51,153) 1px dashed; PADDING-BOTTOM: 2px; COLOR: rgb(0,198,208); FONT-SIZE: 0.9em; TEXT-DECORATION: none" href="http://localhost/"><span style="COLOR: rgb(0,0,0)"><font size="2">http://localhost/</font></span></a><span style="COLOR: rgb(0,0,0)">站点虚拟目录/a.cc访问测试站点，可以看到测试效果。当然，a.cc这个文件在Web服务器上是并不存在的。</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 对HttpHandler的使用，比较典型的有.Net的Web MVC开源项目Maverick。Maverick使用一个Dispatcher类对所有的Http Request进行截取，他以.m作为后缀名向Web服务器提交请求，在Dispatcher中，将.m的后缀去掉，提取Command Name，然后以这个command name从配置文件中加载处理的flow，形成一个chain，依次对chain上的各个command和view进行处理，对各个command和 view的处理结果可能会在chain中选择不同的处理分支，每个处理的Step中将处理结果的HTML写入Response的缓存中进行输出。</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 总体来说，Maverick的框架架构概念很不错，但也存在明显的缺陷，以后有时间再详细的写写它的架构和需要改进之处。</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; 总之，将HttpModule、HttpHandler，以及使用Ajax等将客户端进行封装结合起来，能够给web项目的开发带来非常大的改善空间。</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px"><span style="COLOR: rgb(0,0,0)">Asp.Net HttpHandler实现URL重写的</span><br /> <span style="COLOR: rgb(0,0,0)">我们经常看到很多网站访问文章的时候才用的是***.html 或***.shtml (如本blog的日志访问效果)，其时这写文件在服务器上不存在的，那为什么会出现这样的效果呢，是因为Web服务器上对URL执行了重写，把访问的 URL根据特定的格式重写成内部访问页面来实现的，它的好处是便于用户理解，同时搜索引擎也能更好地收入你的网站，当然其它的好处也很多，这里不做一一介 绍了。</span>&nbsp;<br /> <span style="COLOR: rgb(0,0,0)">本文所讲的是使用Asp.Net中的HttpHandler实现URL重写的，它所实现的原理请看这里，本程序可以处理任何Url，因为我在程序中使用了URL过虑，只有访问文件名是数字的才进行处理，并指在内部执行一个新的页面，并输出数据，代码如下：</span></p>
<p style="TEXT-INDENT: 0px; MARGIN: 0px auto 10px">
<div style="BORDER-BOTTOM: rgb(204,204,204) 1px solid; BORDER-LEFT: rgb(204,204,204) 1px solid; PADDING-BOTTOM: 5px; OVERFLOW-X: auto; OVERFLOW-Y: auto; BACKGROUND-COLOR: rgb(245,245,245); PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: 'Courier New'; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: rgb(204,204,204) 1px solid; BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-TOP: 5px" class="cnblogs_code"><img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Code_Open_Image_175152" onclick="this.style.display='none'; document.getElementById('Code_Open_Text_175152').style.display='none'; getElementById('Code_Closed_Image_175152').style.display='inline'; getElementById('Code_Closed_Text_175152').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width="11" height="16"/><span style="DISPLAY: inline; FONT-FAMILY: 'Courier New'" id="Code_Open_Text_175152"><br /> <span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;1</span><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">public</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">void</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;ProcessRequest(HttpContext&nbsp;Context)<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;2</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_48_616_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_48_616_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_48_616_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_48_616_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif"/></span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_48_616_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;3</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">try</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;4</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_59_539_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_59_539_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_59_539_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_59_539_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/></span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_59_539_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;5</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">申明Request&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;6</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;HttpRequest&nbsp;Request&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Context.Request;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;7</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">取来路Url的绝对路径&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;8</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">string</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Url&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Request.Url.AbsolutePath;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">&nbsp;9</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">取访问的Web文件的开始字符间隔数</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">10</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">int</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;RegStart&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Url.LastIndexOf(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">/</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">)&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">+</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,128)">1</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">11</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">申明一个确定Web文件名是否全是数字</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">12</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;Regex&nbsp;Reg&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">new</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Regex(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">@&#8221;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">\d+</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">);&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">13</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">用正则表达式进行匹配&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">14</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">if</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;(Reg.IsMatch(Url,&nbsp;RegStart))&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">15</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_399_533_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_399_533_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_399_533_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_399_533_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_399_533_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">16</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">//</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)">如果web文件名是数字，则判定是查询相关文章，执行指定页面&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">17</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;Context.Server.Execute(</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">~/PermaLink.aspx?id=</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(128,0,0)">&#8220;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">+</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;Reg.Match(Url,&nbsp;RegStart).Value);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">18</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">19</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">20</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,255)">catch</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">21</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" id="Codehighlighter1_546_614_Open_Image" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_546_614_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_546_614_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_546_614_Closed_Text').style.display='inline';" align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"/></span><span style="FONT-FAMILY: 'Courier New'" id="Codehighlighter1_546_614_Open_Text"><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)">{<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">22</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Context.Response.Redirect(Context.Request.Url.ToString());&nbsp;<br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">23</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif"/>}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">24</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif"/>}</span></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><br /></span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,128,128)">25</span><span style="FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt align="top" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif"/></span></span></div>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><span style="COLOR: rgb(0,0,0)">当然你首先要做的是先建一个类，并继承自IHttpHandler，然后把这段代码拷入，并编译。在Web项目中若要使用此功能，需要在web.config里面加上如下语句：</span><br /> <span style="COLOR: rgb(0,0,0)">&lt;httpHandlers&gt;</span><br /> <span style="COLOR: rgb(0,0,0)">&nbsp;&nbsp;&nbsp; &lt;add verb=&#8221;*&#8221; path=&#8221;*.shtml&#8221; type=&#8221;HttpHandle.UrlRewrite&#8221; /&gt;</span><br /> <span style="COLOR: rgb(0,0,0)">&lt;/httpHandlers&gt;</span><br /> <span style="COLOR: rgb(0,0,0)">同时，还要在IIS中对Web项目进行配置，在Web项目的属性中，在主目录选项卡里，把执行权限改为&#8221;脚本和可执行文件&#8221;，然后打开配置，在应用程序扩展里加上需重写的文件格式的扩展，好了，成事具备，只欠运行了。</span></p>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><span style="COLOR: rgb(0,0,0)"><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><span style="TEXT-ALIGN: center; LINE-HEIGHT: 18px; FONT-FAMILY: 宋体; COLOR: rgb(88,88,88); FONT-SIZE: 12px" class="Apple-style-span">&nbsp;</span></span></span></p>
<h2 style="BORDER-BOTTOM: rgb(200,219,234) 1px solid; PADDING-BOTTOM: 7px; MARGIN: 15px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; COLOR: rgb(11,87,171); FONT-SIZE: 24px; FONT-WEIGHT: bold; PADDING-TOP: 0px"><span style="COLOR: rgb(0,0,0)">httpHandlers和httpModules接口介绍</span></h2>
<p style="PADDING-BOTTOM: 0px; MARGIN: 1em 0px 0.5em; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px"><a href="http://news.ccidnet.com/art/32855/20100723/2126553_3.html">http://news.ccidnet.com/art/32855/20100723/2126553_3.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=296</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sql创建索引</title>
		<link>http://www.mvsay.com/?p=294</link>
		<comments>http://www.mvsay.com/?p=294#comments</comments>
		<pubDate>Tue, 18 Jan 2011 05:30:56 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[学习]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=294</guid>
		<description><![CDATA[探讨数据库建索引的作用。]]></description>
			<content:encoded><![CDATA[<div>探讨数据库建索引的作用。大家都用到过树信息的存放吧，为了说明索引的作用，假设现在存放父子关系的表是这样</div>
<div>id,parentIds，memo</div>
<div>一共两个字段，当新建立一个子节点时，parentIds存放的是从当前节点一直到父节点的一个序列，例如15，16，17，各个父类间使用，呵呵，大家可能已经看出问题来了吧。这样检索父节点下所有自己子节点时相当方便，只要找到它对应的parentIds，用like关键字，上帝保佑，数据量不要太大。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 现在说说like关键字吧，我个人认为对大数据量表，能不用尽量不用，因为用like很有可能造成全表扫描，并且在用like的字段上一定要建立索引，这样可能还会快点，主要看你的like是怎么写的了。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用术语叫一定要符合SARG，下面举例说明，假设parentIds已经建立了索引</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select * from table where parentIds like &#8216;*paraValue&#8217;，</div>
<div>要是这样一定会造成全表扫描的，如果你表数据量超过万级以上，呵呵，那你就得先喝杯咖啡再回来吧。如果用</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select * from table where parentIds like &#8216;paraValue*&#8217;，</div>
<div>这样会根据索引来扫描了，速度会比第一种写法快上一个数量级，在sql里用ctrl+L分析一下当前sql的执行就会看到效果奥。</div>
<div>如果用=找匹配关系，那建索引就太有必要了，</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;select * from table where parentIds =&#8221;paraValue&#8221;,</div>
<div>即使你有百万数量级的数据，那检索也会控制在一秒以内，这是为什么呢？ 学过二叉树的大家都知道，如果一个数组以二叉树的形式来匹配，那速度是不是会很快呢，但是利用二叉树就必须先排序，对了，建立索引的原因就是为了让它排序，这样检索时候数据库就会用二叉树的方式来检索的，速度当然快了。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当然不是索引建的越多越好，因为建立完的索引是需要维护的，所以只有在经常需要扫描的列上建立索引，因为建立的索引是需要维护的，这也是要算在性能损耗里面的奥。</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下面是尽量不要用的比较符例如:</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not,&lt;&gt;,!&gt;,!&lt;,not exists,not in ,not like，</div>
<div>这些非SARG的操作符可以用SARG的操作符代替，下面说一个简单的例子，</div>
<div>select * from table where parentIds&lt;&gt;&#8221;paraValue&#8221; 非SARG的，这样会扫描整个表。</div>
<div>select * from table where parentIds&lt;&#8221;paraValue&#8221; or parentIds&gt;&#8221;paraValue&#8221; SARG的，这样会扫描索引检测数据，可以大大提高检索的性能。</div>
<div>&nbsp;</div>
<div>本文出自 “<a href="http://lidup.blog.51cto.com/">逸凡</a>” 博客，请务必保留此出处<a href="http://lidup.blog.51cto.com/426277/150633">http://lidup.blog.51cto.com/426277/150633</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=294</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE,FF客户端浏览器缓存机制and服务器设置的expires, Cache-Control，no-cache，no-store机制</title>
		<link>http://www.mvsay.com/?p=284</link>
		<comments>http://www.mvsay.com/?p=284#comments</comments>
		<pubDate>Tue, 11 Jan 2011 15:43:11 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[学习]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=284</guid>
		<description><![CDATA[IE,FF客户端浏览器缓存机制 &#038;& 服务器设置的expires, Cache-Control，no-cache，no-store机制

当你建立好一个WEB服务后,通常有两个类型的缓存需要配置:
设置网站有更新的时候html资源马上过期,以便正在浏览的用户可以很快地得到更新. 
设置所有其它资源(例如图片,CSS,javascript脚本)在一定时间后过期. 
]]></description>
			<content:encoded><![CDATA[<div class="postcontent">
<p><font size="3">当你建立好一个WEB服务后,通常有两个类型的</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">需要配置:</font></p>
<ol>
<li><font size="3">设置网站有更新的时候html资源马上过期,以便正在浏览的用户可以很快地得到更新.</font></li>
<li><font size="3">设置所有其它资源(例如图片,CSS,javascript脚本)在一定时间后过期.</font></li>
</ol>
<p> <font size="3">这个</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">方案涵盖</font><a title="Two Simple Rules for HTTP Caching" href="http://blog.httpwatch.com/2007/12/10/two-simple-rules-for-http-caching/"><font color="#2E6AB1" size="3">Two Simple Rules for HTTP Caching</font></a><font size="3">文章中提到关于如何处理更新的一些思想.</font></p>
<p><font size="3">现在</font><a title="HttpWatch 6.0" href="http://blog.httpwatch.com/2008/09/15/httpwatch-version-60/"><font color="#2E6AB1" size="3">HttpWatch 6.0</font></a><font size="3">支持Firefox了,我们想探讨一下Firefox在处理缓存上与IE有些什么不同.设置较长过期时间的使用方式(上面第二条)仍可以直接用于Firefox,但配置1在两者之间还是存在细微差别的.</font></p>
<p><font size="3">在</font><a title="之前的文章" href="http://blog.httpwatch.com/2007/12/10/two-simple-rules-for-http-caching/" target="_blank"><font color="#2E6AB1" size="3">之前的文章</font></a> <font size="3">中,我们把第一条划分为:</font></p>
<ul>
<li><font size="3">某些时候动态HTML页面需要即时从服务器更新以备随时显示-甚至是使用后退按钮的时候.例如,显示银行帐号的状态或在线订单.</font></li>
<li><font size="3">静态HTML页面,比如联系,FAQs或者站点地图等页面,如果它们设置了<code><font face="Arial">Last-Modif</font><a href="http://www.yeeyan.com/articles/tag/ie" target="_blank"><font color="#335533" face="Arial">ie</font></a><font face="Arial">d响应头</font></code>,允许浏览器在需要的时候重新校验,就可以利用到缓存</font><font face="Arial"><code>.</code></font></li>
</ul>
<p><font size="3"></font><font color="#FF0000"><strong>一：火狐机制</strong></font></p>
<p><font size="3">本文剩下部分探讨了Firefox中影响HTML页面</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">的两个重要不同点.</font></p>
<h3><font size="3">1. 使用no-cache防止Firefox</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">无效<br /></font></h3>
<p><font size="3">你可以简单地设置如下的响应头预防IE</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">任何东西:</font></p>
<p><font size="3">Cache-Control: no-cache</font></p>
<p><font size="3">使用了这个响应头的页面不会保存在</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">里,IE总会重新从服务器加载;即使你使用后退按钮.下面这个例子使用HttpWatch监听一个网上商店,当我们在提交订单表单后点击后退按钮,结果如下图:</font></p>
<p><a href="http://blog.httpwatch.com/wp-content/uploads/2008/10/backorder1.png"><font size="3"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="Back button in HttpWatch online store" alt src="http://blog.httpwatch.com/wp-content/uploads/2008/10/backorder1.png" width="520" height="0" size-full wp-image-197/></font></a></p>
<p><font size="3">然而,这个响应头却不能防止Firefox的</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">.这意味着,Firefox在正常访问的情况下,将一直使用缓存的页面,直到它发送GET请求重新检验.并且,如果是通过后退按钮访问页面,Firefox不会再次访问服务器,而是简单直接地从缓存加载.</font></p>
<p><font size="3">那怎样才能关掉Firefox中的</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">呢? 答案很简单,关不了. 因为Firefox依靠缓存中的副本为&#8221;文件-&gt;另存为&#8221;,&#8221;查看源代码&#8221;这样的操作服务.但是,你可以控制页面缓存到哪里及那些缓存条目可以用于显示.</font></p>
<p><font size="3">下面响应头在Firefox中可以防止持久化的</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">,强制页面被缓存到内存中:</font></p>
<p><font size="3">Cache-Control:no-store</font></p>
<p><font size="3">这个头也可以防止使用后退按钮时访问了</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">页面,它将触发一个HTTP GET请求.</font></p>
<p><font size="3">这两个响应头的值组合使用可以在IE与Firefox得到期待的结果:</font></p>
<p><code><font size="3" face="Arial">Cache-Control: no-cache, no-store</font></code></p>
<p><code><font size="3" face="Arial">如下HttpWatch响应头标签所示:<br /></font></code></p>
<p><a href="http://blog.httpwatch.com/wp-content/uploads/2008/10/nostoreheader.png"><font size="3"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="no-store and no-cache headers" alt="no-store and no-cache headers" src="http://blog.httpwatch.com/wp-content/uploads/2008/10/nostoreheader.png" width="397" height="201" wp-image-200 alignnone/></font></a></p>
<h3><font size="3">2. 如果没有设置过期时间Firefox会为你设置一个<br /></font></h3>
<p><font size="3">当IE遇到没有Expires头的http响应时,它就认为永远不能自动使用</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">条目,直到它重新从服务校验.由于IE的临时文件的一个设置项&#8221;检查所在网页的较新版本&#8221;默认为&#8221;自动&#8221;,所以通常都是一个会话做一次.</font></p>
<p><font size="3">这就为控制静态的html内容的</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">提供了一个合理的方式.用户新打开的IE会得到html的最新版本,而缓存的版本就在关闭IE前会一直被使用.</font></p>
<p><font size="3">Firefox处理缺失Expires头的方式不同.如果影响中有Last-Modif</font><a href="http://www.yeeyan.com/articles/tag/ie" target="_blank"><font color="#335533" size="3">ie</font></a><font size="3">d头它就会使用HTTP 1.1规范RFC2616中指定的一个尝试性的过期值:</font></p>
<blockquote style="BACKGROUND-COLOR: #c0c0c0"><p><code><font size="3" face="Arial">(引用规范:)<br /> 并且,如果响应中有Last-Modif</font><a href="http://www.yeeyan.com/articles/tag/ie" target="_blank"><font color="#335533" size="3" face="Arial">ie</font></a><font size="3" face="Arial">d时间值,尝试性的过期值不能超过这个值到现在时间间隔的一个比率,一般设置这个比率为10%.</font></code></p>
</blockquote>
<p><font size="3">计算方式如下:</font><font color="#0000FF"><strong><u>（默认过期时间）</u></strong></font></p>
<p style="PADDING-LEFT: 30px"><u><strong><font color="#FF0000" size="3">过期时间 = 现在时间 + 0.1 * (Last-Modif</font><a href="http://www.yeeyan.com/articles/tag/ie" target="_blank"><font color="#FF0000"></font><font size="3">ie</font></a><font color="#FF0000" size="3">d到现在的时间差)</font></strong></u></p>
<p><font size="3">例如,如果你的静态HTML文件上次修改时间是100天前,那过期时间就是10天之后.下面的示例是一个没有Expires头页面的HttpWatch</font><a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533" size="3">缓存</font></a><font size="3">标签:</font></p>
<p><a href="http://blog.httpwatch.com/wp-content/uploads/2008/10/firefoxexpires.png"><font size="3"><img style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="Firefox assigns an Expiration date/time" alt src="http://blog.httpwatch.com/wp-content/uploads/2008/10/firefoxexpires.png" width="520" height="165" size-full wp-image-203/></font></a></p>
<p><font size="3">Firefox自动设置了过期时间为8天后,因为这个页面大概80天没有被修改过了.</font></p>
<p><font size="3">这意味着,为了保持控制好你的HTML页面,正如我们在</font> <a title="Two Simple Rules for HTTP Caching" href="http://blog.httpwatch.com/2007/12/10/two-simple-rules-for-http-caching/"><font color="#2E6AB1" size="3">Two Simple Rules for HTTP Caching</font></a> <font size="3">文章中讨论过的,你最好为你的静态资源如HTML,图片,CSS文件等,在你的WEB服务器设置一个合适的Expires值.</font></p>
<h3><font size="3">结论</font></h3>
<p>为了确保IE与Firefox的<a href="http://www.yeeyan.com/articles/tag/%E7%BC%93%E5%AD%98" target="_blank"><font color="#335533">缓存</font></a>行为一致,你应该:</p>
<ul>
<li>总是指定一个Expires头. 一般设置-1使用html页面能即时刷新或者对其它如图片,CSS,javascript脚本资源设置一个特定的过期时间</li>
<li>如果你要强制页面刷新,甚至是点击后台按钮的时候,那就设置 <font face="Arial">Cache-Control: no-cache, no-store</font></li>
</ul>
<p> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br /> <font color="#FF0000"><strong>二：IE机制</strong></font><br /> <img alt src="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/moz-screenshot-1.png"/><br /> 1：每次都会到服务器检查最后一次修改时间是否变化 无变化返回304<br /> 2：IE启动时检查<br /> 3：自动检查<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.1：根据IE的默认在浏览器不关闭时，再次访问同一链接都读本地cache<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.2：IE重启时候会根据服务器设置的expire值去判断是否去服务器请求判断，无变化返回304<br /> 4：第一次下载后从不检查<br /> 最好的机制是 3 。根据服务器的设定机制走，会提高访问速度。<br /> 提高访问速度，最好的办法就是减少TCP通信。</p>
<p> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br /> <font color="#FF0000"><strong>三：服务器的设置</strong></font><br /> 参考：<a href="http://hi.baidu.com/%C8%FD%BE%D6%CE%AA%B6%FE/blog/item/30dae1325363ed92a8018e5c.html" target="_blank">http://hi.baidu.com/%C8%FD%BE%D6%CE%AA%B6%FE/blog/item/30dae1325363ed92a8018e5c.html</a></p>
<p> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br /> <font color="#FF0000"><strong>四：服务端设置和客户端的关联</strong></font><br /> 服务器的设置告知浏览器怎么做缓存，缓存时间是多长。客户端同时也可以是CDN。</p>
<p> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br /> <font color="#FF0000"><strong>五：工具类分析</strong></font><br /> IE httpwatch ,FF httpfox YSlow firebug</div>
<div class="postcontent"></div>
<div class="postcontent">=============================</div>
<div class="postcontent"></div>
<div class="postcontent"><strong><font color="#FF0000">六：Silverlight 缓存机制</font></strong>
<div class="postcontent">HTTP请求中浏览器的缓存机制</div>
<div class="postcontent"><a href="http://www.7juice.com/portal.php?mod=view&amp;aid=84">http://www.7juice.com/portal.php?mod=view&amp;aid=84</a></div>
<div class="postcontent"></div>
<div class="postcontent"></div>
<div class="postcontent"><font color="#006699">谁彻底明白cache-control和Expires，以及304响应。</font></div>
<div class="postcontent"><a href="http://www.javaeye.com/topic/294814">http://www.javaeye.com/topic/294814</a></div>
<div class="postcontent"></div>
<div class="postcontent"></div>
<div class="postcontent"><span csdnid="titleStyle"><font size="3">how to Add an Expires or a Cache-Control Header</font></span></div>
<div class="postcontent"><a href="http://topic.csdn.net/u/20100128/16/8b89773f-fd0a-4b0d-bf07-59f0373e4722.html">http://topic.csdn.net/u/20100128/16/8b89773f-fd0a-4b0d-bf07-59f0373e4722.html</a></div>
<div class="postcontent"></div>
<div class="postcontent"></div>
<div class="postcontent">HTTP头的Expires与Cache-control</div>
<div class="postcontent"><a href="http://www.cnblogs.com/yuyii/archive/2008/10/16/1312238.html">http://www.cnblogs.com/yuyii/archive/2008/10/16/1312238.html</a></div>
<div class="postcontent"></div>
<div class="postcontent">在 Silverlight 中管理动态内容交付，第 1 部分 <strong><font size="5">重点</font></strong></div>
<div class="postcontent"><a href="http://msdn.microsoft.com/zh-cn/magazine/dd315412.aspx">http://msdn.microsoft.com/zh-cn/magazine/dd315412.aspx</a></div>
<div class="postcontent">第二部分</div>
<div class="postcontent"><a href="http://msdn.microsoft.com/zh-cn/magazine/dd434650.aspx">http://msdn.microsoft.com/zh-cn/magazine/dd434650.aspx</a></div>
<div class="postcontent">&nbsp;</div>
<div class="postcontent">不错的Blog：&nbsp;<a href="http://www.cnblogs.com/qiantuwuliang/category/179151.html">http://www.cnblogs.com/qiantuwuliang/category/179151.html</a></div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=284</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SL跨域讲解与 SL 调用Webservices</title>
		<link>http://www.mvsay.com/?p=283</link>
		<comments>http://www.mvsay.com/?p=283#comments</comments>
		<pubDate>Tue, 11 Jan 2011 06:03:05 +0000</pubDate>
		<dc:creator>西奥气昂</dc:creator>
				<category><![CDATA[学习]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[跨域]]></category>

		<guid isPermaLink="false">http://www.mvsay.com/?p=283</guid>
		<description><![CDATA[Silverlight 跨域调用其他域下的服务，跨域文件设置。
WebServices安全控制，认证方式,动态调用。
Silverlight 动态调用WebServices,不需要在web.config文件中设置地址。]]></description>
			<content:encoded><![CDATA[<div style="PADDING-BOTTOM: 0px; MIN-HEIGHT: auto; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'lucida Grande',Verdana; HEIGHT: auto; FONT-SIZE: 14px; MARGIN-RIGHT: 0px; PADDING-TOP: 0px" id="mailContentContainer">
<div>Silverlight 跨域调用其他域下的服务，跨域文件设置。<br /> WebServices安全控制，认证方式,动态调用。<br /> Silverlight 动态调用WebServices,不需要在web.config文件中设置地址。</div>
<div>==================================</div>
<div>1.跨域精讲</div>
<div><a href="http://www.cnblogs.com/nasa/archive/2010/01/07/sl-cross-domain.html" target="_blank">http://www.cnblogs.com/nasa/archive/2010/01/07/sl-cross-domain.html</a></div>
<div>==================================</div>
<div>2.WebServices 安全，认证，私有<br /> <a href="http://www.cnblogs.com/houleixx/archive/2009/08/22/WebService-SoapHeader-Security.html" target="_blank">http://www.cnblogs.com/houleixx/archive/2009/08/22/WebService-SoapHeader-Security.html</a></div>
<div>Silverlight调WebService是不能添加SoapHeader的</div>
<div>况且SoapHeader是明文传输的,存放用户密码很容易被截获</div>
<div>我的做法是在宿主页面加载时跳过silverlight端直接调WebService,将用户密码存放在webservice的session中</div>
<div>(如果宿主页面和webservice在同一个项目中,便不必再多写这个webmethod了)</div>
<div>所有WebMethod调用时都要验证此session中的用户密码</div>
<div>但session默认20分钟过期,所以silverlight端要写个timer,定时访问一下这个session,不需返回,每次访问都会延长20分钟</div>
<div>==================================<br /> 3.C# .NET 动态调用webservice的三种方式<br /> <a href="http://topic.csdn.net/u/20090220/10/08c8ca6f-3733-40ff-840e-d6ca6894ab35.html" target="_blank">http://topic.csdn.net/u/20090220/10/08c8ca6f-3733-40ff-840e-d6ca6894ab35.html</a><br /> <a href="http://baitao80000.blog.163.com/blog/static/921870412010826112021892/" target="_blank">http://baitao80000.blog.163.com/blog/static/921870412010826112021892/</a></div>
<div>==================================</div>
<div><a id="ctl03_TitleUrl" href="http://www.cnblogs.com/hackerttao/archive/2009/09/24/1573314.html" name="ctl03_TitleUrl" target="_blank">Silverlight 动态调用 WebService及WCF</a></div>
<p> <!-- --></div>
]]></content:encoded>
			<wfw:commentRss>http://www.mvsay.com/?feed=rss2&#038;p=283</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

