remote client Request---->IIS---->aspnet_isapi.dll-->aspnet_wp.exe-->HttpRuntime---> HttpModule--->HttpHandler Factory--->HttpHandler--->HttpHandler.ProcessRequest()-->Response client Request
如果誤將*.*交給iis處理而沒做相應的進一步處理,可能會導致無法打開應用程序,提示的錯誤可能是“系統檢測到不是aspnet1.1版本”。
dottext中的處理都是經過反射實現的。它自定義了很多section,相關的模塊定義在一個section裏,反射到同一個處理模塊。這樣就靈活的在用到時再加載相關類、對象。
首先看一下處理自定義配置節中反射的方法(XmlSerializerSectionHandler):
{
public object Create(object parent, object configContext, System.Xml.XmlNode section)
{
//XPathNavigator 使用遊標模型從所有數據存儲區讀取數據。
//CreateNavigator 創建 System.Xml.XPath.XPathNavigator 以瀏覽此對象。
XPathNavigator nav = section.CreateNavigator();
//計算表示 XPath 表達式的字符串,並返回類型化結果(數字、布爾值、字符串或節點集)。使用 System.Xml.XPath.XPathNodeIterator 循環訪問一組節點。
string typename = (string) nav.Evaluate("string(@type)");
Type t = Type.GetType(typename);
XmlSerializer ser = new XmlSerializer(t);//將對象序列化到 XML 文檔中和從 XML 文檔中反序列化對象。System.Xml.Serialization.XmlSerializer 使您得以控制如何將對象編碼到 XML 中。
// XmlNodeReader:表示提供對 System.Xml.XmlNode 中 XML 數據進行快速、非緩存、只進訪問的讀取器。
//
return ser.Deserialize(new XmlNodeReader(section));
}
}
XmlSerializerSectionHandler 繼承了IConfigurationSectionHandler接口。繼承並實現了它的方法create。
摘要:
由所有配置節處理程序實現,以分析配置節的 XML。返回的對象被添加到配置集合中,並通過 System.Configuration.ConfigurationSettings.GetConfig(System.String) 訪問。
參數:
parent: 對應父配置節中的配置設置。
configContext: 在從 ASP.NET 配置系統中調用 System.Configuration.IConfigurationSectionHandler.Create(System.Object,System.Object,System.Xml.XmlNode) 時爲 System.Web.Configuration.HttpConfigurationContext。否則,該參數是保留參數,並且爲 null。
section: 一個 System.Xml.XmlNode,它包含配置文件中的配置信息。提供對配置節 XML 內容的直接訪問。
返回值:
配置對象。
舉例應用:
<section name="BlogConfigurationSettings" type="Dottext.Framework.Util.XmlSerializerSectionHandler, Dottext.Framework" />
</configSections>
<BlogConfigurationSettings type="Dottext.Framework.Configuration.BlogConfigurationSettings, Dottext.Framework">
<Tracking enableAggBugs="true" enableWebStats="true" queueStats="false" queueStatsCount="3" enableTrackBacks="false" enablePingBacks="false" pingWeblogs="false" />
<EntryHandlers>
<EntryHandler type="Dottext.Framework.EntryHandling.CommentFormatHandler, Dottext.Framework" postType="Comment" processAction="Insert" processState="PreCommit" isAsync="false" />
<EntryHandler type="Dottext.Framework.EntryHandling.CommentDeliveryHandler, Dottext.Framework" postType="Comment" processAction="Insert" processState="PostCommit" isAsync="true" />
<EntryHandler type="Dottext.Framework.EntryHandling.EntryValidationHandler, Dottext.Framework" postType="BlogPost Article" processAction="Insert Update" processState="PreCommit" isAsync="false" />
<!--<EntryHandler type="Dottext.Framework.EntryHandling.WeblogsPingHandler, Dottext.Framework" postType = "BlogPost" processAction ="Insert Update" processState="PostCommit" isAsync="true" />-->
<EntryHandler type="Dottext.Framework.EntryHandling.TrackBackHandler, Dottext.Framework" postType="BlogPost Article" processAction="Insert Update" processState="PostCommit" isAsync="false" />
<EntryHandler type="Dottext.Framework.EntryHandling.KeyWordHandler, Dottext.Framework" postType="BlogPost Article" processAction="Insert Update" processState="PreCommit" isAsync="false" />
<!--<EntryHandler type="Dottext.Framework.EntryHandling.WebServicePostHandler, Dottext.Framework" postType = "BlogPost Article" processAction ="Insert" processState="PreCommit" isAsync="false" />-->
</EntryHandlers>
</BlogConfigurationSettings>