﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-玩转C科技.NET</title><link>http://www.cnblogs.com/volnet/</link><description>从学会做人开始认识这个世界！http://tinyurl.com/volnethttp://bit.ly/KMzi2</description><language>zh-cn</language><lastBuildDate>Sat, 04 Jul 2009 09:29:16 GMT</lastBuildDate><pubDate>Sat, 04 Jul 2009 09:29:16 GMT</pubDate><ttl>60</ttl><item><title>About Request.Url</title><link>http://www.cnblogs.com/volnet/archive/2009/06/28/1512761.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Sun, 28 Jun 2009 08:47:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/06/28/1512761.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1512761.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/06/28/1512761.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1512761.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1512761.html</trackback:ping><description><![CDATA[<pre class="gc-code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Web;
<span style="color: blue">using </span>System.Web.UI;
<span style="color: blue">using </span>System.Web.UI.WebControls;
<span style="color: blue">using </span>System.Text;

<span style="color: blue">namespace </span>WebAppRequestUrl
{
    <span style="color: blue">public partial class </span><span style="color: #2b91af">_Default </span>: System.Web.UI.<span style="color: #2b91af">Page
    </span>{
        <span style="color: blue">protected void </span>Page_Load(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
        {
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.AbsolutePath"</span>, Request.Url.AbsolutePath);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.AbsolutePath.Split('/')[1]"</span>, Request.Url.AbsolutePath.Split(<span style="color: #a31515">'/'</span>)[1]);

            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.AbsoluteUri"</span>, Request.Url.AbsoluteUri);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.Authority"</span>, Request.Url.Authority);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.DnsSafeHost"</span>, Request.Url.DnsSafeHost);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.Fragment"</span>, Request.Url.Fragment);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.Host"</span>, Request.Url.Host);
            WriteLine&lt;<span style="color: #2b91af">UriHostNameType</span>&gt;(<span style="color: #a31515">"Request.Url.HostNameType"</span>, 
                Request.Url.HostNameType, 
                o =&gt; o.ToString());
            WriteLine&lt;<span style="color: blue">bool</span>&gt;(<span style="color: #a31515">"Request.Url.IsAbsoluteUri"</span>, Request.Url.IsAbsoluteUri);
            WriteLine&lt;<span style="color: blue">bool</span>&gt;(<span style="color: #a31515">"Request.Url.IsDefaultPort"</span>, Request.Url.IsDefaultPort);
            WriteLine&lt;<span style="color: blue">bool</span>&gt;(<span style="color: #a31515">"Request.Url.IsFile"</span>, Request.Url.IsFile);
            WriteLine&lt;<span style="color: blue">bool</span>&gt;(<span style="color: #a31515">"Request.Url.IsLoopback"</span>, Request.Url.IsLoopback);
            WriteLine&lt;<span style="color: blue">bool</span>&gt;(<span style="color: #a31515">"Request.Url.IsUnc"</span>, Request.Url.IsUnc);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.LocalPath"</span>, Request.Url.LocalPath);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.OriginalString"</span>, Request.Url.OriginalString);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.PathAndQuery"</span>, Request.Url.PathAndQuery);
            WriteLine&lt;<span style="color: blue">int</span>&gt;(<span style="color: #a31515">"Request.Url.Port"</span>, Request.Url.Port);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.Query"</span>, Request.Url.Query);
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.Scheme"</span>, Request.Url.Scheme);
            WriteLine&lt;<span style="color: blue">string</span>[]&gt;(<span style="color: #a31515">"Request.Url.Segments"</span>, Request.Url.Segments, o =&gt;
            {
                <span style="color: #2b91af">StringBuilder </span>sb = <span style="color: blue">new </span><span style="color: #2b91af">StringBuilder</span>();
                <span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; o.Length; ++i)
                {
                    sb.AppendFormat(<span style="color: #a31515">"&lt;span style=\"color:blue;\"&gt;{0}&lt;/span&gt;    :{1}&lt;br /&gt;"</span>, i, o[i]);
                }
                <span style="color: blue">return </span>sb.ToString();
            });
            WriteLine&lt;<span style="color: blue">bool</span>&gt;(<span style="color: #a31515">"Request.Url.UserEscaped"</span>, Request.Url.UserEscaped, o =&gt; (o == <span style="color: blue">true </span>? <span style="color: #a31515">"true" </span>: <span style="color: #a31515">"false"</span>));
            WriteLine&lt;<span style="color: blue">string</span>&gt;(<span style="color: #a31515">"Request.Url.UserInfo"</span>, Request.Url.UserInfo);
        }

        <span style="color: blue">private void </span>WriteLine&lt;T&gt;(<span style="color: blue">string </span>name, T output)
        {
            WriteLine&lt;T&gt;(name, output, o =&gt; o.ToString());
        }

        <span style="color: blue">private void </span>WriteLine&lt;T&gt;(<span style="color: blue">string </span>name, T output, <span style="color: #2b91af">Func</span>&lt;T, <span style="color: blue">string</span>&gt; toString)
        {
            <span style="color: blue">if </span>(currentRow++ % 2 == 0)
            {
                Output(<span style="color: #a31515">"&lt;div style=\"border:1px solid; background-color:#cccccc; padding:10px; font-family:Arial;\"&gt;"</span>);
            }
            <span style="color: blue">else
            </span>{
                Output(<span style="color: #a31515">"&lt;div style=\"border:1px solid; background-color:#eeeeee; padding:10px; font-family:Arial;\"&gt;"</span>);
            }
            Output(<span style="color: #a31515">"&lt;b style=\"color:blue;\"&gt;" </span>+ name + <span style="color: #a31515">"&lt;/b&gt;     " </span>+ output.GetType().FullName + <span style="color: #a31515">"&lt;br /&gt;               "</span>);
            Output(<span style="color: #a31515">"&lt;span style=\"font-family:consolas;\"&gt;" </span>+ toString(output) + <span style="color: #a31515">"&lt;/span&gt;"</span>);
            Output(<span style="color: #a31515">"&lt;/div&gt;&lt;br /&gt;"</span>);
        }

        <span style="color: blue">private void </span>Output(<span style="color: blue">string </span>s)
        {
            <span style="color: blue">this</span>.form1.InnerHtml += s;
            <span style="color: blue">this</span>.form1.InnerHtml += <span style="color: #a31515">"\n"</span>;
        }

        <span style="color: blue">private int </span>currentRow;
    }
}
</pre>
<p>下面是输出： 
<p><a href="http://images.cnblogs.com/cnblogs_com/volnet/WindowsLiveWriter/AboutRequest.Url_EBF1/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://images.cnblogs.com/cnblogs_com/volnet/WindowsLiveWriter/AboutRequest.Url_EBF1/image_thumb.png" width="519" height="84"></a> 
<p>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.AbsolutePath</b> System.String<br><span style="font-family: consolas">/Default.aspx</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.AbsolutePath.Split('/')[1]</b> System.String<br><span style="font-family: consolas">Default.aspx</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.AbsoluteUri</b> System.String<br><span style="font-family: consolas">http://localhost:17698/Default.aspx?myQuery=volnet</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Authority</b> System.String<br><span style="font-family: consolas">localhost:17698</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.DnsSafeHost</b> System.String<br><span style="font-family: consolas">localhost</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Fragment</b> System.String<br><span style="font-family: consolas"></span></div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Host</b> System.String<br><span style="font-family: consolas">localhost</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.HostNameType</b> System.UriHostNameType<br><span style="font-family: consolas">Dns</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.IsAbsoluteUri</b> System.Boolean<br><span style="font-family: consolas">True</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.IsDefaultPort</b> System.Boolean<br><span style="font-family: consolas">False</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.IsFile</b> System.Boolean<br><span style="font-family: consolas">False</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.IsLoopback</b> System.Boolean<br><span style="font-family: consolas">True</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.IsUnc</b> System.Boolean<br><span style="font-family: consolas">False</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.LocalPath</b> System.String<br><span style="font-family: consolas">/Default.aspx</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.OriginalString</b> System.String<br><span style="font-family: consolas">http://localhost:17698/Default.aspx?myQuery=volnet</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.PathAndQuery</b> System.String<br><span style="font-family: consolas">/Default.aspx?myQuery=volnet</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Port</b> System.Int32<br><span style="font-family: consolas">17698</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Query</b> System.String<br><span style="font-family: consolas">?myQuery=volnet</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Scheme</b> System.String<br><span style="font-family: consolas">http</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.Segments</b> System.String[]<br><span style="font-family: consolas"><span style="color: blue">0</span> :/<br><span style="color: blue">1</span> :Default.aspx<br></span></div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #cccccc; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.UserEscaped</b> System.Boolean<br><span style="font-family: consolas">false</span> </div><br>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: #eeeeee; padding-left: 10px; padding-right: 10px; font-family: arial; border-top: 1px solid; border-right: 1px solid; padding-top: 10px"><b style="color: blue">Request.Url.UserInfo</b> System.String<br><span style="font-family: consolas"></span></div><img src ="http://www.cnblogs.com/volnet/aggbug/1512761.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47970/" target="_blank">19岁天才黑客发布首个iPhone 3GS破解软件</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>The ThreadAbortException from Response.End()</title><link>http://www.cnblogs.com/volnet/archive/2009/06/28/response_end-with-ThreadAbortException.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Sat, 27 Jun 2009 19:38:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/06/28/response_end-with-ThreadAbortException.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1512501.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/06/28/response_end-with-ThreadAbortException.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1512501.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1512501.html</trackback:ping><description><![CDATA[<pre class="gc-code"><span style="color: gray">/// &lt;devdoc&gt;
///    &lt;para&gt; 
///       </span><span style="color: green">Terminates execution of the current page and begins execution of a new
</span><span style="color: gray">///       </span><span style="color: green">request using the supplied URL path.
</span><span style="color: gray">///       </span><span style="color: green">If preserveForm is false, the QueryString and Form collections are cleared.
</span><span style="color: gray">///    &lt;/para&gt; 
/// &lt;/devdoc&gt;
</span><span style="color: blue">public void </span>Transfer(<span style="color: blue">string </span>path, <span style="color: blue">bool </span>preserveForm) { 
    Page page = _context.Handler <span style="color: blue">as </span>Page; 
    <span style="color: blue">if </span>((page != <span style="color: blue">null</span>) &amp;&amp; page.IsCallback) {
        <span style="color: blue">throw new </span><span style="color: #2b91af">ApplicationException</span>(SR.GetString(SR.Transfer_not_allowed_in_callback)); 
    }

    <span style="color: green">// execute child request
 
    </span><strong>Execute(path, <span style="color: blue">null</span>, preserveForm);</strong>
 
    <span style="color: green">// suppress the remainder of the current one 

    </span>_context.Response.End(); 
}</pre>
<p>都问页面跳转，然后大家都知道Server.Transfer与Request.Redirect的区别。</p>
<p>因为是页面跳转，所以理所应当地被用上了Response.End方法，而此举却引发了一些异常（<a title="http://support.microsoft.com/kb/312629" href="http://support.microsoft.com/kb/312629">http://support.microsoft.com/kb/312629</a>）。</p>
<p>所以用Server.Execute就可以避免这个错误了。</p>
<p>详细如下：</p>
<p class="quote">对于 Response.End，调用 HttpContext.Current.ApplicationInstance.CompleteRequest 方法而不是 Response.End 以跳过 Application_EndRequest 事件的代码执行。<br>对于 Response.Redirect，请使用重载 Response.Redirect(String url, bool endResponse)，该重载对 endResponse 参数传递 false 以取消对 Response.End 的内部调用。例如： <br>&nbsp; Response.Redirect ("nextpage.aspx", false); 
<p>如果使用此替代方法，将执行 Response.Redirect 后面的代码。<br>对于 Server.Transfer，请改用 Server.Execute 方法。</p>
<p>顺便让我们看看Response.End都做了些什么</p><pre class="gc-code"><span style="color: green">/*
 * Cancelles handler processing of the current request 
 * throws special [non-]exception uncatchable by the user code
 * to tell application to stop module execution. 
 */ 

</span><span style="color: gray">/// &lt;devdoc&gt; 
///    &lt;para&gt;</span><span style="color: green">Sends all currently buffered output to the client then closes the
</span><span style="color: gray">///       </span><span style="color: green">socket connection.</span><span style="color: gray">&lt;/para&gt;
/// &lt;/devdoc&gt;
</span><span style="color: blue">public void </span>End() { 

    <span style="color: blue">if </span>(_context.IsInCancellablePeriod) { 
        InternalSecurityPermissions.ControlThread.Assert(); 
        <span style="color: #2b91af">Thread</span>.CurrentThread.Abort(<span style="color: blue">new </span>HttpApplication.CancelModuleException(<span style="color: blue">false</span>));
    } 
    <span style="color: blue">else </span>{
        <span style="color: green">// when cannot abort execution, flush and supress further output
        </span><span style="color: blue">if </span>(!_flushing) { <span style="color: green">// ignore Reponse.End while flushing (in OnPreSendHeaders)
            </span>Flush(); 
            _ended = <span style="color: blue">true</span>;
 
            <span style="color: blue">if </span>(_context.ApplicationInstance != <span style="color: blue">null</span>) { 
                _context.ApplicationInstance.CompleteRequest();
            } 
        }
    }
}</pre>
<p>关于InternalSecurityPermissions.ControlThread.Assert()请参考<a title="http://msdn.microsoft.com/zh-cn/library/system.security.codeaccesspermission.assert(VS.80).aspx" href="http://msdn.microsoft.com/zh-cn/library/system.security.codeaccesspermission.assert(VS.80).aspx">http://msdn.microsoft.com/zh-cn/library/system.security.codeaccesspermission.assert(VS.80).aspx</a></p><pre class="gc-code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Web;
<span style="color: blue">using </span>System.Web.UI;
<span style="color: blue">using </span>System.Web.UI.WebControls;
<span style="color: blue">using </span>System.Threading;

<span style="color: blue">namespace </span>WebAppThreadAbortException
{
    <span style="color: blue">public partial class </span><span style="color: #2b91af">_Default </span>: System.Web.UI.<span style="color: #2b91af">Page
    </span>{
        <span style="color: blue">protected void </span>Page_Load(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
        {
             Do1Nothing();
            <span style="color: green">// Do1NothingWithoutException();
            // Do2ResponseEnd();
            // Do3Redirect();
            // Do4Transfer();
        </span>}

        <span style="color: blue">private void </span>Do1Nothing()
        {
            <span style="color: #2b91af">Thread</span>.CurrentThread.Abort();
        }

        <span style="color: blue">private void </span>Do1NothingWithoutException()
        {
            <span style="color: blue">try
            </span>{
                <span style="color: #2b91af">Thread</span>.CurrentThread.Abort();
            }
            <span style="color: blue">catch
            </span>{
                <span style="color: #2b91af">Thread</span>.ResetAbort();
            }
        }

        <span style="color: blue">private void </span>Do2ResponseEnd()
        {
            <span style="color: blue">try
            </span>{
                Response.End();
            }
            <span style="color: blue">catch </span>(<span style="color: #2b91af">ThreadAbortException </span>ex)
            {
                Response.Write(FormatException(ex.ToString()));
            }
        }

        <span style="color: blue">private void </span>Do3Redirect()
        {
            <span style="color: blue">try
            </span>{
                Response.Redirect(<span style="color: #a31515">"NextPage.aspx"</span>);
            }
            <span style="color: blue">catch </span>(<span style="color: #2b91af">ThreadAbortException </span>ex)
            {
                Response.Write(FormatException(ex.ToString()));
            }
        }

        <span style="color: blue">private void </span>Do4Transfer()
        {
            <span style="color: blue">try
            </span>{
                Server.Transfer(<span style="color: #a31515">"NextPage.aspx"</span>);
            }
            <span style="color: blue">catch </span>(<span style="color: #2b91af">ThreadAbortException </span>ex)
            {
                Response.Write(FormatException(ex.ToString()));
            }
        }

        <span style="color: blue">private string </span>FormatException(<span style="color: blue">string </span>exception)
        {
            <span style="color: blue">return string</span>.Format(<span style="color: #a31515">"&lt;div style=\"border:1px solid; padding:10px; background-color:yellow;\"&gt;{0}&lt;/div&gt;"</span>, exception);
        }
    }
}</pre>
<p>
<div style="border-bottom: 1px solid; border-left: 1px solid; padding-bottom: 10px; background-color: yellow; padding-left: 10px; padding-right: 10px; border-top: 1px solid; border-right: 1px solid; padding-top: 10px">
<p>疑问：</p>
<p>既然我们说Response.End将引发一个ThreadAbortException，但为何直接调用Response.End的时候并不会出现异常页面呢？但是我们在页面上直接使用<span style="color: #2b91af">Thread</span>.CurrentThread.Abort(); 却会出现异常页面，请问这是为什么呢？</p></div><img src ="http://www.cnblogs.com/volnet/aggbug/1512501.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47970/" target="_blank">19岁天才黑客发布首个iPhone 3GS破解软件</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[Code reverse]Int to Hex &amp;amp; Hex to int</title><link>http://www.cnblogs.com/volnet/archive/2009/06/27/1512427.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Sat, 27 Jun 2009 13:57:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/06/27/1512427.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1512427.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/06/27/1512427.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1512427.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1512427.html</trackback:ping><description><![CDATA[<pre class="gc-code"><span style="color: blue">private static int </span>HexToInt(<span style="color: blue">char </span>h) { 
    <span style="color: blue">return</span>( h &gt;= <span style="color: #a31515">'0' </span>&amp;&amp; h &lt;= <span style="color: #a31515">'9' </span>) ? h - <span style="color: #a31515">'0' </span>: 
    ( h &gt;= <span style="color: #a31515">'a' </span>&amp;&amp; h &lt;= <span style="color: #a31515">'f' </span>) ? h - <span style="color: #a31515">'a' </span>+ 10 :
    ( h &gt;= <span style="color: #a31515">'A' </span>&amp;&amp; h &lt;= <span style="color: #a31515">'F' </span>) ? h - <span style="color: #a31515">'A' </span>+ 10 : 
    -1;
}

<span style="color: blue">internal static char </span>IntToHex(<span style="color: blue">int </span>n) { 
    Debug.Assert(n &lt; 0x10);
 
    <span style="color: blue">if </span>(n &lt;= 9) 
        <span style="color: blue">return</span>(<span style="color: blue">char</span>)(n + (<span style="color: blue">int</span>)<span style="color: #a31515">'0'</span>);
    <span style="color: blue">else 
        return</span>(<span style="color: blue">char</span>)(n - 10 + (<span style="color: blue">int</span>)<span style="color: #a31515">'a'</span>);
}</pre>
<p>以上代码源自Microsoft ASP.NET HttpServerUtility.cs源码。
<img src ="http://www.cnblogs.com/volnet/aggbug/1512427.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47969/" target="_blank">新浪邮箱大本营粉墨登场！Sina.cn开放注册</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>如何获取本地局域网内的可用IP地址</title><link>http://www.cnblogs.com/volnet/archive/2009/06/14/how-to-get-LAN-IPs.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Sat, 13 Jun 2009 20:23:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/06/14/how-to-get-LAN-IPs.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1502870.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/06/14/how-to-get-LAN-IPs.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1502870.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1502870.html</trackback:ping><description><![CDATA[<p>命题：如何获取本地局域网内的可用IP地址？</p> <p>从这个命题，可以看出这里要解释的概念，什么是<a href="http://baike.baidu.com/view/788.htm" target="_blank">局域网</a>？详见（<a title="http://baike.baidu.com/view/788.htm" href="http://baike.baidu.com/view/788.htm">http://baike.baidu.com/view/788.htm</a>）</p> <p>当然，在这篇文章中我们是指我们可以有效ping通的IP地址。</p> <p><strong>思路1：</strong></p> <p>穷举：</p> <p>假设我们知道我们的IP地址为192.168.1.1 /24，即子网掩码为255.255.255.0，那么通过匹配192.168.1.*，所有可ping通的IP地址都为我们当前可获知的IP地址。</p> <p>这里有一点需要解释一下，就是这个地址要ping地通，就以经验来告诉我们，这是错的。因为很多时候很多计算机显然连接在一个HUB或者SWITCH上，但是根本无法ping通，仅仅只是因为它的计算机可能的安全性问题所致。</p> <p>但我们考虑到我们要ping通的计算机才有意义，因此，这种思路也是一种方案。</p> <p>事实上，后续的几种方案依然存在这个问题。</p> <p>穷举的方案详见：<a title="http://heisetoufa.javaeye.com/blog/253099" href="http://heisetoufa.javaeye.com/blog/253099">http://heisetoufa.javaeye.com/blog/253099</a></p> <p><strong>思路2：</strong></p> <p>利用DOS命令net view：<a title="http://tech.sina.com.cn/s/2006-04-07/1446895256.shtml" href="http://tech.sina.com.cn/s/2006-04-07/1446895256.shtml">http://tech.sina.com.cn/s/2006-04-07/1446895256.shtml</a></p> <p>事实上这里要引进一种在.NET程序中利用DOS命令来解决的方案。</p> <p>首先下面的类用来解决传递DOS命令的方案（很简单）：</p><pre class="gc-code"><span style="color: blue">namespace </span>WinFormShowLocalIPs
{
    <span style="color: blue">using </span>System;
    <span style="color: blue">using </span>System.Diagnostics;
    <span style="color: blue">public static class </span><span style="color: #2b91af">DOS
    </span>{
        <span style="color: blue">public static void </span>CMD(
            <span style="color: blue">string </span>commandNameOrFileName,
            <span style="color: blue">string </span>arguments,
            <span style="color: #2b91af">DataReceivedEventHandler </span>callback)
        {
            <span style="color: blue">try
            </span>{
                <span style="color: #2b91af">Process </span>process = <span style="color: blue">new </span><span style="color: #2b91af">Process</span>();
                process.StartInfo.FileName = commandNameOrFileName;
                process.StartInfo.Arguments = arguments;
                process.StartInfo.UseShellExecute = <span style="color: blue">false</span>;
                process.StartInfo.RedirectStandardInput = <span style="color: blue">true</span>;
                process.StartInfo.RedirectStandardOutput = <span style="color: blue">true</span>;
                process.StartInfo.RedirectStandardError = <span style="color: blue">true</span>;
                process.StartInfo.CreateNoWindow = <span style="color: blue">true</span>;
                process.OutputDataReceived += <span style="color: blue">new </span><span style="color: #2b91af">DataReceivedEventHandler</span>(callback);
                process.Start();
                process.BeginOutputReadLine();
                process.WaitForExit();
                process.Close();
            }
            <span style="color: blue">catch </span>(<span style="color: #2b91af">Exception </span>ex)
            {
                <span style="color: blue">throw new </span><span style="color: #2b91af">ArgumentException</span>(<span style="color: #a31515">"启动DOS命令失败！"</span>, ex);
            }
        }
    }
}
</pre>
<p>然后就是调用DOS命令，并解析运行DOS后返回值的步骤：</p><pre class="gc-code"><span style="color: blue">namespace </span>WinFormShowLocalIPs
{
    <span style="color: blue">using </span>System;
    <span style="color: blue">using </span>System.Net;
    <span style="color: blue">using </span>System.Diagnostics;
    <span style="color: blue">using </span>System.Threading;
    <span style="color: blue">using </span>System.Net.Sockets;
    <span style="color: blue">public class </span><span style="color: #2b91af">DnsHelper
    </span>{

        <span style="color: blue">public void </span>AsynGetAddresses(<span style="color: #2b91af">DataReceivedEventHandler </span>receivedHostEntry)
        {
            ReceivedHostEntry = receivedHostEntry;

            <span style="color: #2b91af">DOS</span>.CMD(<span style="color: #a31515">"net.exe"</span>, <span style="color: #a31515">"view"</span>, process_OutputDataReceived);
        }

        <span style="color: blue">private void </span>process_OutputDataReceived(<span style="color: blue">object </span>sender, <span style="color: #2b91af">DataReceivedEventArgs </span>e)
        {
            <span style="color: blue">if </span>(!<span style="color: blue">string</span>.IsNullOrEmpty(e.Data))
            {
                <span style="color: blue">if </span>(e.Data.StartsWith(<span style="color: #a31515">"\\\\"</span>))
                {
                    <span style="color: blue">try
                    </span>{
                        <span style="color: blue">string </span>hostName = e.Data.Substring(2).TrimEnd();
                        <span style="color: #2b91af">ResolveState </span>ioContext = <span style="color: blue">new </span><span style="color: #2b91af">ResolveState</span>(hostName);
                        GetHostEntryFinished.Reset();
                        <span style="color: #2b91af">IAsyncResult </span>result = <span style="color: #2b91af">Dns</span>.BeginGetHostEntry(ioContext.HostName,
                            <span style="color: blue">new </span><span style="color: #2b91af">AsyncCallback</span>(GetHostAddressesCallback), ioContext);
                        <span style="color: blue">if </span>(GetHostEntryFinished.WaitOne())
                        {
                            <span style="color: blue">if </span>(ReceivedHostEntry != <span style="color: blue">null</span>)
                            {
                                ReceivedHostEntry(ioContext, e);
                            }
                        }
                    }
                    <span style="color: blue">catch
                    </span>{

                    }
                }
            }
        }

        <span style="color: #2b91af">ManualResetEvent </span>GetHostEntryFinished = <span style="color: blue">new </span><span style="color: #2b91af">ManualResetEvent</span>(<span style="color: blue">false</span>);

        <span style="color: blue">void </span>GetHostAddressesCallback(<span style="color: #2b91af">IAsyncResult </span>ar)
        {
            <span style="color: #2b91af">ResolveState </span>ioContext = (<span style="color: #2b91af">ResolveState</span>)ar.AsyncState;

            <span style="color: blue">try
            </span>{
                ioContext.IPs = <span style="color: #2b91af">Dns</span>.EndGetHostEntry(ar);
            }
            <span style="color: blue">catch</span>(<span style="color: #2b91af">SocketException </span>se)
            { 
                ioContext.HasError = <span style="color: blue">true</span>;
                ioContext.ErrorMessage = <span style="color: #a31515">"GetHostEntry has error!"</span>;
                ioContext.Error = se;
            }
            GetHostEntryFinished.Set();
        }

        <span style="color: blue">public class </span><span style="color: #2b91af">ResolveState
        </span>{
            <span style="color: blue">string </span>hostName;
            <span style="color: #2b91af">IPHostEntry </span>resolvedIPs;

            <span style="color: blue">public </span>ResolveState(<span style="color: blue">string </span>host)
            {
                hostName = host;
            }

            <span style="color: blue">public </span><span style="color: #2b91af">IPHostEntry </span>IPs
            {
                <span style="color: blue">get </span>{ <span style="color: blue">return </span>resolvedIPs; }
                <span style="color: blue">set </span>{ resolvedIPs = <span style="color: blue">value</span>; }
            }
            <span style="color: blue">public string </span>HostName
            {
                <span style="color: blue">get </span>{ <span style="color: blue">return </span>hostName; }
                <span style="color: blue">set </span>{ hostName = <span style="color: blue">value</span>; }
            }
            <span style="color: blue">private bool </span>hasError = <span style="color: blue">false</span>;
            <span style="color: blue">public bool </span>HasError
            {
                <span style="color: blue">get
                </span>{
                    <span style="color: blue">return </span>hasError;
                }
                <span style="color: blue">set
                </span>{
                    hasError = <span style="color: blue">value</span>;
                }
            }

            <span style="color: blue">public string </span>ErrorMessage
            {
                <span style="color: blue">get</span>;
                <span style="color: blue">set</span>;
            }
            <span style="color: blue">public </span><span style="color: #2b91af">Exception </span>Error
            {
                <span style="color: blue">get</span>;
                <span style="color: blue">set</span>;
            }
        }

        <span style="color: blue">public </span><span style="color: #2b91af">DataReceivedEventHandler </span>ReceivedHostEntry
        {
            <span style="color: blue">get</span>;
            <span style="color: blue">set</span>;
        }
    }
}
</pre>
<p>然后就是界面调用的方案：</p><pre class="gc-code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.ComponentModel;
<span style="color: blue">using </span>System.Data;
<span style="color: blue">using </span>System.Drawing;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>System.Windows.Forms;

<span style="color: blue">namespace </span>WinFormShowLocalIPs
{
    <span style="color: blue">using </span>System.Diagnostics;
    <span style="color: blue">using </span>System.Net;
    <span style="color: blue">using </span>System.Threading;
    <span style="color: blue">using </span>System.DirectoryServices;
    <span style="color: blue">using </span>System.ComponentModel;

    <span style="color: blue">public partial class </span><span style="color: #2b91af">Form1 </span>: <span style="color: #2b91af">Form
    </span>{
        <span style="color: blue">public </span>Form1()
        {
            InitializeComponent();
            lbIps.Width = 200;
        }

        <span style="color: blue">private </span><span style="color: #2b91af">StringBuilder </span>sb = <span style="color: blue">new </span><span style="color: #2b91af">StringBuilder</span>(<span style="color: #a31515">"Result:\n"</span>);
        <span style="color: blue">private void </span>btnShowIps_Click(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
        {
            <span style="color: #2b91af">Thread </span>thread = <span style="color: blue">new </span><span style="color: #2b91af">Thread</span>(<span style="color: blue">new </span><span style="color: #2b91af">ThreadStart</span>(
                () =&gt;
                {
                    <span style="color: blue">try
                    </span>{
                        <span style="color: #2b91af">DnsHelper </span>d = <span style="color: blue">new </span><span style="color: #2b91af">DnsHelper</span>();
                        d.AsynGetAddresses(ReceivedHostEntry);
                        SetLbIps(sb.ToString());
                        sb.Remove(0, sb.Length);
                    }
                    <span style="color: blue">finally
                    </span>{
                        <span style="color: #2b91af">InterfaceHelper</span>.ShowWaitingEffect(<span style="color: blue">false</span>, <span style="color: blue">null</span>);
                    }
                }));
            thread.Start();

            <span style="color: #2b91af">InterfaceHelper</span>.ShowWaitingEffect(<span style="color: blue">true</span>, (o, args) =&gt; {
                <span style="color: green">//AppendWaiting(args.Data);
                </span><span style="color: blue">string </span>welcome = <span style="color: #a31515">"Please wait!"</span>;
                <span style="color: blue">if </span>(args.Count == 1)
                {
                    SetLbIps(welcome);
                    AppendLbIps(<span style="color: blue">string</span>.Format(<span style="color: #a31515">"[{0}]"</span>, args.Count));
                }
                <span style="color: blue">else
                </span>{
                    <span style="color: #2b91af">StringBuilder </span>waiting = <span style="color: blue">new </span><span style="color: #2b91af">StringBuilder</span>();
                    SetLbIps(welcome);
                    AppendLbIps(<span style="color: blue">string</span>.Format(<span style="color: #a31515">"[{0}]"</span>, args.Count));
                    <span style="color: blue">while </span>(args.Count-- != 0)
                    {
                        waiting.Append(<span style="color: #a31515">"."</span>);
                    }
                    AppendLbIps(waiting.ToString());
                }
            });
        }

        <span style="color: blue">void </span>ReceivedHostEntry(<span style="color: blue">object </span>sender, <span style="color: #2b91af">DataReceivedEventArgs </span>e)
        {
            WinFormShowLocalIPs.<span style="color: #2b91af">DnsHelper</span>.<span style="color: #2b91af">ResolveState </span>state 
                = sender <span style="color: blue">as </span>WinFormShowLocalIPs.<span style="color: #2b91af">DnsHelper</span>.<span style="color: #2b91af">ResolveState</span>;
            <span style="color: blue">if </span>(state != <span style="color: blue">null </span>&amp;&amp; !state.HasError)
            {
                sb.AppendFormat(<span style="color: #a31515">"HostName:{0}\n"</span>, state.HostName);
                <span style="color: blue">foreach </span>(<span style="color: #2b91af">IPAddress </span>ip <span style="color: blue">in </span>state.IPs.AddressList)
                {
                    sb.AppendLine(ip.ToString());
                }
            }
            <span style="color: blue">else if </span>(state != <span style="color: blue">null </span>&amp;&amp; state.HasError)
            {
                <span style="color: green">//sb.AppendLine("----------error start----------");
                //sb.AppendLine(state.HostName);
                //sb.AppendLine(state.ErrorMessage);
                //sb.AppendLine("-----------error end-----------");
            </span>}
        }

        <span style="color: blue">delegate void </span><span style="color: #2b91af">SetAsyncCallBack</span>(<span style="color: blue">string </span>text);
        <span style="color: blue">void </span>SetLbIps(<span style="color: blue">string </span>args)
        {
            <span style="color: blue">if </span>(lbIps.InvokeRequired)
            {
                <span style="color: #2b91af">SetAsyncCallBack </span>d = <span style="color: blue">new </span><span style="color: #2b91af">SetAsyncCallBack</span>(SetLbIps);
                <span style="color: blue">this</span>.Invoke(d, <span style="color: blue">new object</span>[] { args });
            }
            <span style="color: blue">else
            </span>{
                lbIps.Text = args;
            }
        }
        <span style="color: blue">void </span>AppendLbIps(<span style="color: blue">string </span>args)
        {
            <span style="color: blue">if </span>(lbIps.InvokeRequired)
            {
                <span style="color: #2b91af">SetAsyncCallBack </span>d = <span style="color: blue">new </span><span style="color: #2b91af">SetAsyncCallBack</span>(AppendLbIps);
                <span style="color: blue">this</span>.Invoke(d, <span style="color: blue">new object</span>[] { args });
            }
            <span style="color: blue">else
            </span>{
                lbIps.Text += args;
            }
        }
    }
}
</pre>
<p>上面的方案中包含以下有用信息：</p>
<p>1、对Windows 窗体控件进行线程安全调用（<a title="http://msdn.microsoft.com/zh-cn/library/ms171728.aspx" href="http://msdn.microsoft.com/zh-cn/library/ms171728.aspx">http://msdn.microsoft.com/zh-cn/library/ms171728.aspx</a>）</p>
<p>2、如何显示进度条（文本进度条），基于多线程以及线程切换。</p>
<p><strong>思路3：</strong></p>
<p>利用DirectoryEntry来完成任务。关于DirectoryEntry，请参考MSDN（<a title="http://msdn.microsoft.com/zh-cn/library/system.directoryservices.directoryentry.aspx" href="http://msdn.microsoft.com/zh-cn/library/system.directoryservices.directoryentry.aspx">http://msdn.microsoft.com/zh-cn/library/system.directoryservices.directoryentry.aspx</a>）</p><pre class="gc-code"><span style="color: blue">private void </span>btnShowIPs2_Click(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
{
    <span style="color: #2b91af">Thread </span>thread = <span style="color: blue">new </span><span style="color: #2b91af">Thread</span>(<span style="color: blue">new </span><span style="color: #2b91af">ThreadStart</span>(
        () =&gt;
        {
            <span style="color: blue">try
            </span>{
                <span style="color: #2b91af">DirectoryEntry </span>root = <span style="color: blue">new </span><span style="color: #2b91af">DirectoryEntry</span>(<span style="color: #a31515">"WinNT:"</span>);
                <span style="color: blue">foreach </span>(<span style="color: #2b91af">DirectoryEntry </span>Domain <span style="color: blue">in </span>root.Children)
                {
                    <span style="color: green">//枚举工作组或域 
                    </span>sb.AppendLine(Domain.Name);
                    <span style="color: blue">foreach </span>(<span style="color: #2b91af">DirectoryEntry </span>Computer <span style="color: blue">in </span>Domain.Children)
                    {
                        <span style="color: green">//枚举指定工作组或域的计算机

                        </span><span style="color: blue">if </span>(Computer.SchemaClassName.Equals(<span style="color: #a31515">"Computer"</span>))
                        {
                            <span style="color: #2b91af">IPHostEntry </span>ipHost;
                            <span style="color: blue">try
                            </span>{
                                ipHost = <span style="color: #2b91af">Dns</span>.GetHostEntry(Computer.Name);
                                <span style="color: blue">foreach </span>(<span style="color: #2b91af">IPAddress </span>ip <span style="color: blue">in </span>ipHost.AddressList)
                                {
                                    sb.AppendFormat(<span style="color: #a31515">"{0}:"</span>, Computer.Name);
                                    sb.AppendLine(ip.ToString());
                                }
                            }
                            <span style="color: blue">catch
                            </span>{

                            }
                        }
                    }
                }
                SetLbIps(sb.ToString());
                sb.Remove(0, sb.Length);
            }
            <span style="color: blue">finally
            </span>{
                <span style="color: #2b91af">InterfaceHelper</span>.ShowWaitingEffect(<span style="color: blue">false</span>, <span style="color: blue">null</span>);
            }
        }));
    thread.Start();
    <span style="color: #2b91af">InterfaceHelper</span>.ShowWaitingEffect(<span style="color: blue">true</span>, (o, args) =&gt;
    {
        AppendLbIps(args.Data);
    });
}</pre>
<p>关于InterfaceHelper类：</p><pre class="gc-code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>System.Threading;

<span style="color: blue">namespace </span>WinFormShowLocalIPs
{
    <span style="color: blue">public class </span><span style="color: #2b91af">InterfaceHelper
    </span>{
        <span style="color: blue">static </span><span style="color: #2b91af">Thread </span>waitingThread = <span style="color: blue">null</span>;
        <span style="color: blue">static int </span>waitingCount = 0;
        <span style="color: blue">public static void </span>ShowWaitingEffect(<span style="color: blue">bool </span>showSwitch, <span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">InfoEventArgs</span>&gt; showHandler)
        {
            <span style="color: blue">if </span>(showSwitch &amp;&amp; showHandler == <span style="color: blue">null</span>)
            {
                <span style="color: blue">throw new </span><span style="color: #2b91af">ArgumentNullException</span>(<span style="color: #a31515">"The handler can not be null!"</span>);
            }
            <span style="color: blue">if </span>(!showSwitch &amp;&amp; waitingThread != <span style="color: blue">null</span>)
            {
                waitingThread.Abort();
                waitingThread = <span style="color: blue">null</span>;
                waitingCount = 0;
                <span style="color: blue">return</span>;
            }
            showHandler(<span style="color: blue">null</span>, <span style="color: blue">new </span><span style="color: #2b91af">InfoEventArgs</span>(<span style="color: #a31515">"Please wait for a while."</span>) { Count = waitingCount });
            waitingThread = <span style="color: blue">new </span><span style="color: #2b91af">Thread</span>(<span style="color: blue">new </span><span style="color: #2b91af">ThreadStart</span>(
                () =&gt;
                {
                    <span style="color: blue">while </span>(showSwitch)
                    {
                        ++waitingCount;
                        showHandler(<span style="color: blue">null</span>, <span style="color: blue">new </span><span style="color: #2b91af">InfoEventArgs</span>(<span style="color: #a31515">"."</span>) { Count = waitingCount });
                        <span style="color: #2b91af">Thread</span>.Sleep(1000);
                    }
                }));
            waitingThread.Start();
        }

        <span style="color: blue">public class </span><span style="color: #2b91af">InfoEventArgs </span>: <span style="color: #2b91af">EventArgs
        </span>{
            <span style="color: blue">private string </span>args = <span style="color: blue">string</span>.Empty;
            <span style="color: blue">public </span>InfoEventArgs() { }
            <span style="color: blue">public </span>InfoEventArgs(<span style="color: blue">string </span>args)
            {
                <span style="color: blue">this</span>.args = args;
            }

            <span style="color: blue">public string </span>Data
            {
                <span style="color: blue">get </span>{ <span style="color: blue">return </span>args; }
                <span style="color: blue">set </span>{ args = <span style="color: blue">value</span>; }
            }

            <span style="color: blue">public int </span>Count
            { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        }
    }
}
</pre> <img src ="http://www.cnblogs.com/volnet/aggbug/1502870.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47968/" target="_blank">IE市场份额首次跌破60%</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>简历要怎样写呢？面试要注意哪些细节？</title><link>http://www.cnblogs.com/volnet/archive/2009/05/28/interview.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Wed, 27 May 2009 20:28:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/05/28/interview.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1491219.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/05/28/interview.html#Feedback</comments><slash:comments>21</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1491219.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1491219.html</trackback:ping><description><![CDATA[<p>已经有很多文章来描述这个主题了，我这里就讲讲我的一些看法。 <p>给你一份简历，你会怎么看？如果你不是每天吃饱了没事做专业面试的？你会怎么面？ <p>如果给你一份简历，嗯，项目经历要介绍，但注意不是项目介绍，有人做了某某产品系统，让他做个介绍，他就开始跟我介绍这个产品，电话这头的我倒是顺便了解了一个新产品，但对他而言丝毫没有帮助，因为我很清晰，这个人肯定理解力或者表达力有欠缺，或者这个项目压根就没啥可提的。当然如果这个东西如果我感兴趣的话可能直接给你加分。 <p>会的技术写，不会的技术不写，可能会可能不会的，宁可不写。很多职位不需要你从WPF，WCF，WF，Silverlight，MVC，Ajax，jQuery等全部都写进来，因为我通常只会挑选我见到的问，你不写你会WPF，我是不会问你的，特别是这个职位如果是ASP.NET的话，但是如果你有好几个项目都用了WPF，并且你声称自己小有牛劲的话，那你惨了，本来你不需要回答这个问题的，但现在你需要了，因为我可能也会一点，可能不如你，但你不一定比我见过的人牛，所以你可能被认为很差，或者认为学习态度有问题。如果你这个技术还是你其他技术中比较牛的，那说明你别的更一般，嗯，就挂了。 <p>针对你应聘的岗位写经验，告诉我你在这方面很强大就好了，咱就考这方面，当然，如果你精通算法数据结构的话，或者在某些科学领域有所探索，请告诉我，因为大部分学计算机的人可能对这些基本能力很看重，起码我是这样，这样我会给你优先的机会。这也就包括你可能有些特长，比如特别喜欢请同事吃饭等，我都可以优先考虑。当然不要忽悠我！哈哈 <p>如果要用英文写简历，请也带上中文，不要搞得自己很牛，因为有的人可能还愤青呢，就是看你假洋鬼子不录用你怎么招？因为今天有同事面对一箩筐的简历，决定让那个假洋鬼子去国外呆着，这里容不下他。中英文都有则显得专业，只有英文，当然我可以给你打个电话，但我同事不肯，这时候不知道吃亏的是谁？ <p>如果你投递了简历，请保持手机在线！居然有人关机了！好吧，再见！本来是通过了，但因为通过的人比较多，需要再小筛一两个，现在你关机了，优先退出。 <p>请务必在简历中写上手机号码！可能你的手机号码在邮件title中，或者在别的地方，但中间可能经历了QQ，MSN，U盘等中转，你的手机号码还在原来的地方，如果我只有一份简历，我会回去找回你的号码，如果我有一堆，那你就自动靠后了，直到我想起你来为止。所以请务必保持手机号码和简历的原子性。 <p>不要写太长，简明扼要就可以，长，没人会觉得你了不起，美观点就可以了。有见到个简历，是用纵向平均分开的表格，这个没有关系，但是最右边一列类似详细内容，左边的全部都是10个字符以内的，造成了我拖动了4-5页纸，只看到一点点的信息。这很不好，当然我也不介意，因为你让我觉得简历太多了，我直接电话让你自我介绍好了。 <p>去面试前务必检查带上几份简历，不要以为这个问题每个人都知道，不知道的居然远远超过知道的，太可恶了。 <p>注意，记住，对你不会的尽量闭口不谈，不会的就说不会，不要忽悠我，点头也不代表同意你的观点，也可能在误导你，不过只是要套出你是真懂还是假懂。 <p>祝大家都顺心如意，端午节快乐！更多信息请加入<a href="http://www.cnblogs.com/" target="_blank">博客园</a>&#8220;<a href="http://space.cnblogs.com/group/100855/" target="_blank">面试笔试</a>&#8221;小组！</p> <img src ="http://www.cnblogs.com/volnet/aggbug/1491219.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47965/" target="_blank">Google App Engine宕机6小时——云的安全在哪里？</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>[CodeReserve]GetAttributeFromHeader</title><link>http://www.cnblogs.com/volnet/archive/2009/03/19/1416921.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Thu, 19 Mar 2009 08:31:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/03/19/1416921.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1416921.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/03/19/1416921.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1416921.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1416921.html</trackback:ping><description><![CDATA[<p>以下代码可以从http header中获取一个attribute的值。如： </p><pre class="gc-code"><span style="color: #2b91af">String </span>b = GetAttributeFromHeader(ContentType, <span style="color: #a31515">"boundary"</span>);</pre>
<hr>
<pre class="gc-code"><span style="color: blue">private static </span><span style="color: #2b91af">String </span>GetAttributeFromHeader(<span style="color: #2b91af">String </span>headerValue, <span style="color: #2b91af">String </span>attrName) {
    <span style="color: blue">if </span>(headerValue == <span style="color: blue">null</span>)
        <span style="color: blue">return null</span>; 

    <span style="color: blue">int </span>l = headerValue.Length; 
    <span style="color: blue">int </span>k = attrName.Length; 

    <span style="color: green">// find properly separated attribute name 
    </span><span style="color: blue">int </span>i = 1; <span style="color: green">// start searching from 1

    </span><span style="color: blue">while </span>(i &lt; l) {
        i = <span style="color: #2b91af">CultureInfo</span>.InvariantCulture.CompareInfo.IndexOf(headerValue, attrName, i, <span style="color: #2b91af">CompareOptions</span>.IgnoreCase); 
        <span style="color: blue">if </span>(i &lt; 0)
            <span style="color: blue">break</span>; 
        <span style="color: blue">if </span>(i+k &gt;= l) 
            <span style="color: blue">break</span>;
 
        <span style="color: blue">char </span>chPrev = headerValue[i-1];
        <span style="color: blue">char </span>chNext = headerValue[i+k];
        <span style="color: blue">if </span>((chPrev == <span style="color: #a31515">';' </span>|| chPrev == <span style="color: #a31515">',' </span>|| <span style="color: #2b91af">Char</span>.IsWhiteSpace(chPrev)) &amp;&amp; (chNext == <span style="color: #a31515">'=' </span>|| <span style="color: #2b91af">Char</span>.IsWhiteSpace(chNext)))
            <span style="color: blue">break</span>; 

        i += k; 
    } 

    <span style="color: blue">if </span>(i &lt; 0 || i &gt;= l) 
        <span style="color: blue">return null</span>;

    <span style="color: green">// skip to '=' and the following whitespaces
    </span>i += k; 
    <span style="color: blue">while </span>(i &lt; l &amp;&amp; <span style="color: #2b91af">Char</span>.IsWhiteSpace(headerValue[i]))
        i++; 
    <span style="color: blue">if </span>(i &gt;= l || headerValue[i] != <span style="color: #a31515">'='</span>) 
        <span style="color: blue">return null</span>;
    i++; 
    <span style="color: blue">while </span>(i &lt; l &amp;&amp; <span style="color: #2b91af">Char</span>.IsWhiteSpace(headerValue[i]))
        i++;
    <span style="color: blue">if </span>(i &gt;= l)
        <span style="color: blue">return null</span>; 

    <span style="color: green">// parse the value 
    </span><span style="color: #2b91af">String </span>attrValue = <span style="color: blue">null</span>; 

    <span style="color: blue">int </span>j; 

    <span style="color: blue">if </span>(i &lt; l &amp;&amp; headerValue[i] == <span style="color: #a31515">'"'</span>) {
        <span style="color: blue">if </span>(i == l-1)
            <span style="color: blue">return null</span>; 
        j = headerValue.IndexOf(<span style="color: #a31515">'"'</span>, i+1);
        <span style="color: blue">if </span>(j &lt; 0 || j == i+1) 
            <span style="color: blue">return null</span>; 

        attrValue = headerValue.Substring(i+1, j-i-1).Trim(); 
    }
    <span style="color: blue">else </span>{
        <span style="color: blue">for </span>(j = i; j &lt; l; j++) {
            <span style="color: blue">if </span>(headerValue[j] == <span style="color: #a31515">' ' </span>|| headerValue[j] == <span style="color: #a31515">','</span>) 
                <span style="color: blue">break</span>;
        } 
 
        <span style="color: blue">if </span>(j == i)
            <span style="color: blue">return null</span>; 

        attrValue = headerValue.Substring(i, j-i).Trim();
    }
 
    <span style="color: blue">return </span>attrValue;
} </pre><img src ="http://www.cnblogs.com/volnet/aggbug/1416921.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47961/" target="_blank">微软新推社交网站Windows Live Planet</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>Forms in HTML documents - Form submission</title><link>http://www.cnblogs.com/volnet/archive/2009/03/19/Forms-in-HTML-documents-Form-submission.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Wed, 18 Mar 2009 19:44:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/03/19/Forms-in-HTML-documents-Form-submission.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1416202.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/03/19/Forms-in-HTML-documents-Form-submission.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1416202.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1416202.html</trackback:ping><description><![CDATA[摘要: <p>内容涉及：form（表单）提交的相关细节。</p>
<ul>
<li>&lt;form method=”get/post” … 其中get只支持ASCII字符，而post支持<a href="http://www.w3.org/TR/html401/references.html#ref-ISO10646">[ISO10646]</a>字符集。</li>
<li><a name="successful-controls">Successful controls</a>的定义。</li>
<li>get方法将form data set附加到action的URI后，post则将它放在form的body中发送。</li>
<li>user agent（e.g IE, Firefox …）处理form submission的四个步骤。</li>
<li><a name="didx-applicationx-www-form-urlencoded">application/x-www-form-urlencoded</a>和multipart/form-data的区别。其中包括&nbsp;&nbsp;<a href='http://www.cnblogs.com/volnet/archive/2009/03/19/Forms-in-HTML-documents-Form-submission.html'>阅读全文</a><img src ="http://www.cnblogs.com/volnet/aggbug/1416202.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47961/" target="_blank">微软新推社交网站Windows Live Planet</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>ASP.NET MVC &amp;ndash; Nerdinner - notes</title><link>http://www.cnblogs.com/volnet/archive/2009/03/14/aspnetmvc-Nerdinner-notes.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Sat, 14 Mar 2009 15:52:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/03/14/aspnetmvc-Nerdinner-notes.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1412147.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/03/14/aspnetmvc-Nerdinner-notes.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1412147.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1412147.html</trackback:ping><description><![CDATA[<script language="javascript" type="text/javascript">
function __v_exchange(namea, nameb){
	var a = document.getElementById(namea);
	var b = document.getElementById(nameb);
	if(a != null && b != null)
	{
		var tmp_style_display = a.style.display;
		a.style.display = b.style.display;
		b.style.display = tmp_style_display;
	}
}
</script> <p>The blog record any valuable point from the free book. 《<a href="http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf" target="_blank">Professional ASP.NET MVC1.0</a>》! </p> <p>The blog write by <a href="http://tinyurl.com/volnet" target="_blank">volnet</a>.</p> <p>1.Page 12/196</p> <p>ASP.NET MVC projects by default have six top-level directories:</p> <table style="border-bottom: 1px solid; border-left: 1px solid; border-top: 1px solid; border-right: 1px solid" border="1" cellspacing="0" cellpadding="2" width="768"> <tbody> <tr> <td style="background-color: black; color: white" valign="top" width="101">Directory</td> <td style="background-color: black; color: white" valign="top" width="665">Purpose</td></tr> <tr> <td valign="top" width="101">/Controllers</td> <td valign="top" width="665">Where you put Controller classes that handle URL requests</td></tr> <tr> <td valign="top" width="101">/Models</td> <td valign="top" width="665">Where you put classes that represent and manipulate data</td></tr> <tr> <td valign="top" width="101">/Views <br></td> <td valign="top" width="665">Where you put UI template files that are responsible for rendering output</td></tr> <tr> <td valign="top" width="101">/Scripts</td> <td valign="top" width="665">Where you put JavaScript library files and scripts (.js)</td></tr> <tr> <td valign="top" width="101">/Content</td> <td valign="top" width="665">Where you put CSS and image files, and other non-dynamic/non-JavaScript content</td></tr> <tr> <td valign="top" width="101">/App_Data</td> <td valign="top" width="665">Where you store data files you want to read/write.</td></tr></tbody></table> <p>ASP.NET MVC <u>does not require</u> this structure. In fact, developers working on large applications will<br>typically partition the application up across multiple projects to make it more manageable (for example:<br>data model classes often go in a separate class library project from the web application). The default<br>project structure, however, does provide a nice default directory convention that we can use to keep<br>our application concerns clean.  <p>2.Page 28/196</p> <p>In a model-view-controller framework the term “model” refers to the objects that represent the data of<br>the application, as well as the corresponding <u>domain logic that integrates validation and business rules<br>with it.</u> The model is in many ways the “heart” of an MVC-based application, and as we’ll see later fundamentally drives the behavior of it.  <p>3.Page 31/196</p> <p>By default the LINQ to SQL designer automatically "pluralizes" table and column names when it creates<br>classes based on a database schema. For example: the "Dinners" table in our example above resulted in<br>a "Dinner" class. …  <p>By default the LINQ to SQL designer also inspects the primary key/foreign key relationships of the tables,<br>and based on them automatically creates default "relationship associations" between the different<br>model classes it creates. For example, …</p> <p><a href="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/ASP.NETMVCNerdinnernotes_E401/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="LINQ to SQL inspects the primary key/foreign key relationships of the tables" border="0" alt="LINQ to SQL inspects the primary key/foreign key relationships of the tables" src="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/ASP.NETMVCNerdinnernotes_E401/image_thumb.png" width="567" height="330"></a> </p> <p>4.Page 42/196</p> <p>We can use .NET’s regular expression support to implement this phone validation support. Below is a<br>simple PhoneValidator implementation that we can add to our project that enables us to add countryspecific<br>Regex pattern checks:</p> <p><a href="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/ASP.NETMVCNerdinnernotes_E401/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="code" border="0" alt="code" src="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/ASP.NETMVCNerdinnernotes_E401/image_thumb_1.png" width="757" height="489"></a>&nbsp;<br></p> <div style="border-bottom: 1px solid; border-left: 1px solid; background-color: #cefcef; display: block; height: 20px; border-top: 1px solid; border-right: 1px solid" id="a_code" onclick="__v_exchange('a_code', 'b_code');">Click here to get code!</div> <div style="border-bottom: 1px solid; border-left: 1px solid; background-color: yellow; display: none; border-top: 1px solid; border-right: 1px solid" id="b_code" onclick="__v_exchange('a_code', 'b_code');"> <p style="background-color: orange">All these code is the same as before. (Click here to collapse!)</p> <p>public class PhoneValidator {<br>static IDictionary&lt;string, Regex&gt; countryRegex =<br>new Dictionary&lt;string, Regex&gt;() {<br>{ "USA", new Regex("^[2-9]\\d{2}-\\d{3}-\\d{4}$")},<br>{ "UK", new<br>Regex("(^1300\\d{6}$)|(^1800|1900|1902\\d{6}$)|(^0[2|3|7|8]{1}[0-<br>9]{8}$)|(^13\\d{4}$)|(^04\\d{2,3}\\d{6}$)")},<br>{ "Netherlands", new Regex("(^\\+[0-9]{2}|^\\+[0-<br>9]{2}\\(0\\)|^\\(\\+[0-9]{2}\\)\\(0\\)|^00[0-9]{2}|^0)([0-9]{9}$|[0-9\\-<br>\\s]{10}$)")},<br>};<br>public static bool IsValidNumber(string phoneNumber, string country) {<br>if (country != null &amp;&amp; countryRegex.ContainsKey(country))<br>return countryRegex[country].IsMatch(phoneNumber);<br>else<br>return false;<br>}<br>public static IEnumerable&lt;string&gt; Countries {<br>get {<br>return countryRegex.Keys;<br>}<br>}<br>}</p></div> <p>5.Page 43/196</p> <p>Because our validation and business rules are implemented within our domain model layer, and not<br>within the UI layer, they will be applied and used across all scenarios within our application. We can<br>later change or add business rules and have all code that works with our Dinner objects honor them.<br>Having the flexibility to change business rules in one place, without having these changes ripple<br>throughout the application and UI logic, is a sign of a well-written application, and a benefit that an MVC<br>framework helps encourage. <p>6.Page 44/196</p> <p>Web-based MVC frameworks map URLs to server code in a slightly different way. Instead of mapping<br>incoming URLs to files, they instead map URLs to methods on classes. These classes are called<br>“Controllers” and they are responsible for processing incoming HTTP requests, handling user input,<br>retrieving and saving data, and determining the response to send back to the client (display HTML,<br>download a file, redirect to a different URL, etc). <p>7.Page /196</p><img src ="http://www.cnblogs.com/volnet/aggbug/1412147.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47960/" target="_blank">火狐3.5版被指推出太匆忙：存在50多个漏洞</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>【搞笑】Best Computer Programming Videos【转】【视频】</title><link>http://www.cnblogs.com/volnet/archive/2009/02/27/Best-computer-programming-videos.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Fri, 27 Feb 2009 09:47:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/02/27/Best-computer-programming-videos.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1399786.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/02/27/Best-computer-programming-videos.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1399786.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1399786.html</trackback:ping><description><![CDATA[摘要: &nbsp;&nbsp;<a href='http://www.cnblogs.com/volnet/archive/2009/02/27/Best-computer-programming-videos.html'>阅读全文</a><img src ="http://www.cnblogs.com/volnet/aggbug/1399786.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47959/" target="_blank">Google对手机搜索进行优化升级</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item><item><title>循环调用静态变量，你知道它的结果吗？</title><link>http://www.cnblogs.com/volnet/archive/2009/02/25/1398216.html</link><dc:creator>volnet（可以叫我大V）</dc:creator><author>volnet（可以叫我大V）</author><pubDate>Wed, 25 Feb 2009 13:05:00 GMT</pubDate><guid>http://www.cnblogs.com/volnet/archive/2009/02/25/1398216.html</guid><wfw:comment>http://www.cnblogs.com/volnet/comments/1398216.html</wfw:comment><comments>http://www.cnblogs.com/volnet/archive/2009/02/25/1398216.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnblogs.com/volnet/comments/commentRss/1398216.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/volnet/services/trackbacks/1398216.html</trackback:ping><description><![CDATA[<pre class="gc-code"><span style="color: blue">namespace </span>CA_CycleInvokeStaticVariable
{
    <span style="color: blue">using </span>System;

    <span style="color: blue">class </span><span style="color: #2b91af">A
    </span>{
        <span style="color: blue">public static int </span>X;
        <span style="color: blue">static </span>A()
        {
            X = <span style="color: #2b91af">B</span>.Y + 1;
        }
    }
    <span style="color: blue">class </span><span style="color: #2b91af">B
    </span>{
        <span style="color: blue">public static int </span>Y = <span style="color: #2b91af">A</span>.X + 1;
        <span style="color: blue">static </span>B() { }
        <span style="color: blue">static void </span>Main(<span style="color: blue">string</span>[] args)
        {
            <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">"X = {0}, Y = {1}"</span>, <span style="color: #2b91af">A</span>.X, <span style="color: #2b91af">B</span>.Y);
        }
    }
}
<span style="color: green">//X = 1, Y = 2</span></pre>
<p><a href="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/686ec2e19774_12858/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/686ec2e19774_12858/image_thumb_1.png" width="500" height="212"></a> </p>
<p><a href="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/686ec2e19774_12858/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.cnblogs.com/images/cnblogs_com/volnet/WindowsLiveWriter/686ec2e19774_12858/image_thumb.png" width="500" height="278"></a></p><img src ="http://www.cnblogs.com/volnet/aggbug/1398216.html?type=1" width = "1" height = "1" /><br/><br/>--------------------------<br/>新闻：<a href="http://news.cnblogs.com/n/47958/" target="_blank">风声又起 Windows 7 RTM版7月13日完成</a><br/>网站导航: <a href="http://www.cnblogs.com" target="_blank">博客园首页</a>&nbsp;&nbsp;<a href="http://news.cnblogs.com" target="_blank">新闻</a>&nbsp;&nbsp;<a href="http://dotnet.cnblogs.com" target="_blank">.NET频道</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com" target="_blank">社区</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/q/" target="_blank">博问</a>&nbsp;&nbsp;<a href="http://space.cnblogs.com/ing/" target="_blank">闪存</a>&nbsp;&nbsp;<a href="http://zzk.cnblogs.com" target="_blank">找找看</a>]]></description></item></channel></rss>