版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p><b> 中文4960字</b></p><p><b> 網(wǎng)絡(luò)編程的技術(shù)解析</b></p><p> 1.Asp.net的身份驗(yàn)證</p><p> Asp.net的身份驗(yàn)證有有三種,分別是"Windows | Forms | Passport",其中又以Forms驗(yàn)證用的
2、最多,也最靈活。</p><p> Forms 驗(yàn)證方式對(duì)基于用戶的驗(yàn)證授權(quán)提供了很好的支持,可以通過一個(gè)登錄頁(yè)面驗(yàn)證用戶的身份,將此用戶的身份發(fā)回到客戶端的Cookie,之后此用戶再訪問這個(gè)web應(yīng)用就會(huì)連同這個(gè)身份Cookie一起發(fā)送到服務(wù)端。服務(wù)端上的授權(quán)設(shè)置就可以根據(jù)不同目錄對(duì)不同用戶的訪問授權(quán)進(jìn)行控制了。</p><p> 下面大概的看一下Forms的過程。</p>
3、;<p> Forms身份驗(yàn)證基本原理:</p><p> 要采用Forms身份驗(yàn)證,先要在應(yīng)用程序根目錄中的Web.config中做相應(yīng)的設(shè)置:</p><p> <authentication mode="forms"></p><p> <forms name=".ASPXAUTH &quo
4、t; loginUrl="/login.aspx" timeout="30" path= "/"></p><p> </forms></authentication></p><p> 其中<authentication mode= "forms"> 表示本應(yīng)用程
5、序采用Forms驗(yàn)證方式。</p><p> 1. <forms>標(biāo)簽中的name表示指定要用于身份驗(yàn)證的 HTTP Cookie。默認(rèn)情況下,name 的值是 .ASPXAUTH。采用此種方式驗(yàn)證用戶后,以此用戶的信息建立一個(gè)FormsAuthenticationTicket類型的身份驗(yàn)證票,再加密序列化為一個(gè)字符串,最后將這個(gè)字符串寫到客戶端的name指定名字的Cookie中.一旦這個(gè)Cooki
6、e寫到客戶端后,此用戶再次訪問這個(gè)web應(yīng)用時(shí)會(huì)將連同Cookie一起發(fā)送到服務(wù)端,服務(wù)端將會(huì)知道此用戶是已經(jīng)驗(yàn)證過的. </p><p> 再看一下身份驗(yàn)證票都包含哪些信息呢,我們看一下FormsAuthenticationTicket類: CookiePath: 返回發(fā)出 Cookie 的路徑。注意,窗體的路徑設(shè)置為 /。由于窗體區(qū)分大小寫,這是為了防止站點(diǎn)中的 URL 的大小寫不一致而采取的一種保護(hù)措施。
7、這在刷新 Cookie 時(shí)使用Expiration: 獲取Cookie 過期的日期/時(shí)間。</p><p> IsPersistent: 如果已發(fā)出持久的Cookie,則返回 true。否則,身份驗(yàn)證Cookie將限制在瀏覽器生命周期范圍內(nèi)。</p><p> IssueDate: 獲取最初發(fā)出 Cookie 的日期/時(shí)間。</p><p> Name: 獲取
8、與身份驗(yàn)證 Cookie 關(guān)聯(lián)的用戶名。</p><p> UserData :獲取存儲(chǔ)在 Cookie 中的應(yīng)用程序定義字符串。</p><p> Version: 返回字節(jié)版本號(hào)供將來使用。</p><p> 2.<forms>標(biāo)簽中的loginUrl指定如果沒有找到任何有效的身份驗(yàn)證Cookie,為登錄將請(qǐng)求重定向到的 URL。默認(rèn)值為 de
9、fault.aspx。loginUrl指定的頁(yè)面就是用來驗(yàn)證用戶身份的,一般此頁(yè)面提供用戶輸入用戶名和密碼,用戶提交后由程序來根據(jù)自己的需要來驗(yàn)證用戶的合法性(大多情況是將用戶輸入信息同數(shù)據(jù)庫(kù)中的用戶表進(jìn)行比較),如果驗(yàn)證用戶有效,則生成同此用戶對(duì)應(yīng)的身份驗(yàn)證票,寫到客戶端的Cookie,最后將瀏覽器重定向到用戶初試請(qǐng)求的頁(yè)面.一般是用FormsAuthentication.RedirectFromLoginPage 方法來完成生成身份
10、驗(yàn)證票,寫回客戶端,瀏覽器重定向等一系列的動(dòng)作。</p><p> public static void RedirectFromLoginPage( string userName, bool createPersistentCookie, string strCookiePath );</p><p> 其中 userName: 就是此用戶的標(biāo)示,用來標(biāo)志此用戶的唯一標(biāo)示,不一定要
11、映射到用戶賬戶名稱. createPersistentCookie: 標(biāo)示是否發(fā)出持久的 Cookie。若不是持久Cookie,Cookie的有效期Expiration屬性有當(dāng)前時(shí)間加上web.config中timeout的時(shí)間,每次請(qǐng)求頁(yè)面時(shí),在驗(yàn)證身份過程中,會(huì)判斷是否過了有效期的一半,要是的話更新一次cookie的有效期;若是持久cookie,Expiration屬性無(wú)意義,這時(shí)身份驗(yàn)證票的有效期有cookie的Expires決定
12、,RedirectFromLoginPage方法給Expires屬性設(shè)定的是50年有效期。</p><p> strCookiePath: 標(biāo)示將生成的Cookie的寫到客戶端的路徑,身份驗(yàn)證票中保存這個(gè)路徑是在刷新身份驗(yàn)證票Cookie時(shí)使用(這也是生成Cookie的Path),若沒有strCookiePath 參數(shù),則使用web.config中 path屬性的設(shè)置。</p><p>
13、 這里可以看到,此方法參數(shù)只有三個(gè),而身份驗(yàn)證票的屬性有七個(gè),不足的四個(gè)參數(shù)是這么來的:</p><p> IssueDate: Cookie發(fā)出時(shí)間由當(dāng)前時(shí)間得出。</p><p> Expiration:過期時(shí)間由當(dāng)前時(shí)間和下面要說的<forms>標(biāo)簽中timeout參數(shù)算出。此參數(shù)對(duì)非持久性cookie有意義。</p><p> UserD
14、ata: 這個(gè)屬性可以用應(yīng)用程序?qū)懭胍恍┯脩舳x的數(shù)據(jù),此方法沒有用到這個(gè)屬性,只是簡(jiǎn)單的將此屬性置為空字符串,請(qǐng)注意此屬性,在后面我們將要使用到這個(gè)屬性。</p><p> Version: 版本號(hào)由系統(tǒng)自動(dòng)提供.</p><p> RedirectFromLoginPage方法生成生成身份驗(yàn)證票后,會(huì)調(diào)用FormsAuthentication.Encrypt 方法,將身份驗(yàn)證票加密
15、為字符串,這個(gè)字符串將會(huì)是以.ASPXAUTH為名字的一個(gè)Cookie的值。這個(gè)Cookie的其它屬性的生成:Domain,Path屬性為確省值,Expires視createPersistentCookie參數(shù)而定,若是持久cookie,Expires設(shè)為50年以后過期;若是非持久cookie,Expires屬性不設(shè)置。</p><p> 生成身份驗(yàn)證Cookie后,將此Cookie加入到Response.Co
16、okies中,等待發(fā)送到客戶端。最后RedirectFromLoginPage方法調(diào)用FormsAuthentication.GetRedirectUrl方法獲取到用戶原先請(qǐng)求的頁(yè)面,重定向到這個(gè)頁(yè)面。</p><p> 3. <forms>標(biāo)簽中的timeout和path,是提供了身份驗(yàn)證票寫入到Cookie過期時(shí)間和默認(rèn)路徑。</p><p> 以上就是基于Forms身
17、份驗(yàn)證的過程,它完成了對(duì)用戶身份的確認(rèn)。下面介紹基于Forms身份驗(yàn)證的訪問授權(quán)。</p><p> 驗(yàn)證了身份,是要使用這個(gè)身份,根據(jù)不同的身份我們可以進(jìn)行不同的操作,處理,最常見的就是對(duì)不同的身份進(jìn)行不同的授權(quán),F(xiàn)orms驗(yàn)證就提供這樣的功能。Forms授權(quán)是基于目錄的,可以針對(duì)某個(gè)目錄來設(shè)置訪問權(quán)限,比如,這些用戶可以訪問這個(gè)目錄,那些用戶不能訪問這個(gè)目錄。同樣,授權(quán)設(shè)置是在你要控制的那個(gè)目錄下的web.
18、config文件中來設(shè)置:</p><p> <authorization></p><p> <allow users="comma-separated list of users" </p><p> roles="comma-separated list of roles"</
19、p><p> verbs="comma-separated list of verbs" /></p><p> <deny users="comma-separated list of users"</p><p> roles="comma-separated list of roles"
20、</p><p> verbs="comma-separated list of verbs" /></p><p> </authorization></p><p> <allow>標(biāo)簽表示允許訪問,其中的屬性</p><p> 1. users:一個(gè)逗號(hào)分隔的用戶名列表,這些用戶
21、名已被授予對(duì)資源的訪問權(quán)限。問號(hào) (?) 允許匿名用戶;星號(hào) (*) 允許所有用戶。</p><p> 2. roles:一個(gè)逗號(hào)分隔的角色列表,這些角色已被授予對(duì)資源的訪問權(quán)限。</p><p> 3. verbs:一個(gè)逗號(hào)分隔的 HTTP 傳輸方法列表,這些 HTTP 傳輸方法已被授予對(duì)資源的訪問權(quán)限。注冊(cè)到 ASP.NET 的謂詞為 GET、HEAD、POST 和DEBUG。&l
22、t;/p><p> <deny>標(biāo)簽表示不允許訪問。其中的屬性同上面的。</p><p> 在運(yùn)行時(shí),授權(quán)模塊迭代通過 <allow> 和 <deny> 標(biāo)記,直到它找到適合特定用戶的第一個(gè)訪問規(guī)則。然后,它根據(jù)找到的第一項(xiàng)訪問規(guī)則是 <allow> 還是 <deny> 規(guī)則來允許或拒絕對(duì) URL 資源的訪問。Machine.co
23、nfig 文件中的默認(rèn)身份驗(yàn)證規(guī)則是 <allow users="*"/>,因此除非另行配置,否則在默認(rèn)情況下會(huì)允許訪問。</p><p> 2.ASP.NET調(diào)用存儲(chǔ)過程</p><p> 在使用.NET的過程中,數(shù)據(jù)庫(kù)訪問是一個(gè)很重要的部分,特別是在B/S系統(tǒng)的構(gòu)建過程中,數(shù)據(jù)庫(kù)操作幾乎成為了一個(gè)必不可少的操作。調(diào)用存儲(chǔ)過程實(shí)現(xiàn)數(shù)據(jù)庫(kù)操作使很多程序員
24、使用的方法,而且大多數(shù)的程序員都是能使用存儲(chǔ)過程就使用存儲(chǔ)過程,很少直接使用SQL語(yǔ)句,所以存儲(chǔ)過程是很有用而且很重要的。</p><p><b> 1.存儲(chǔ)過程簡(jiǎn)介</b></p><p> 簡(jiǎn)單的說,存儲(chǔ)過程是由一些SQL語(yǔ)句和控制語(yǔ)句組成的被封裝起來的過程,它駐留在數(shù)據(jù)庫(kù)中,可以被客戶應(yīng)用程序調(diào)用,也可以從另一個(gè)過程或觸發(fā)器調(diào)用。它的參數(shù)可以被傳遞和返回。與
25、應(yīng)用程序中的函數(shù)過程類似,存儲(chǔ)過程可以通過名字來調(diào)用,而且它們同樣有輸入?yún)?shù)和輸出參數(shù)。</p><p> 根據(jù)返回值類型的不同,我們可以將存儲(chǔ)過程分為三類:返回記錄集的存儲(chǔ)過程, 返回?cái)?shù)值的存儲(chǔ)過程(也可以稱為標(biāo)量存儲(chǔ)過程),以及行為存儲(chǔ)過程。顧名思義,返回記錄集的存儲(chǔ)過程的執(zhí)行結(jié)果是一個(gè)記錄集,典型的例子是從數(shù)據(jù)庫(kù)中檢索出符合某一個(gè)或幾個(gè)條件的記錄;返回?cái)?shù)值的存儲(chǔ)過程執(zhí)行完以后返回一個(gè)值,例如在數(shù)據(jù)庫(kù)中執(zhí)行
26、一個(gè)有返回值的函數(shù)或命令;最后,行為存儲(chǔ)過程僅僅是用來實(shí)現(xiàn)數(shù)據(jù)庫(kù)的某個(gè)功能,而沒有返回值,例如在數(shù)據(jù)庫(kù)中的更新和刪除操作。</p><p> 2.使用存儲(chǔ)過程的好處</p><p> 相對(duì)于直接使用SQL語(yǔ)句,在應(yīng)用程序中直接調(diào)用存儲(chǔ)過程有以下好處:</p><p> (1)減少網(wǎng)絡(luò)通信量。調(diào)用一個(gè)行數(shù)不多的存儲(chǔ)過程與直接調(diào)用SQL語(yǔ)句的網(wǎng)絡(luò)通信量可能不會(huì)有很
27、大的差別,可是如果存儲(chǔ)過程包含上百行SQL語(yǔ)句,那么其性能絕對(duì)比一條一條的調(diào)用SQL語(yǔ)句要高得多。</p><p> (2)執(zhí)行速度更快。有兩個(gè)原因:首先,在存儲(chǔ)過程創(chuàng)建的時(shí)候,數(shù)據(jù)庫(kù)已經(jīng)對(duì)其進(jìn)行了一次解析和優(yōu)化。其次,存儲(chǔ)過程一旦執(zhí)行,在內(nèi)存中就會(huì)保留一份這個(gè)存儲(chǔ)過程,這樣下次再執(zhí)行同樣的存儲(chǔ)過程時(shí),可以從內(nèi)存中直接調(diào)用。</p><p> (3)更強(qiáng)的適應(yīng)性:由于存儲(chǔ)過程對(duì)數(shù)據(jù)庫(kù)的
28、訪問是通過存儲(chǔ)過程來進(jìn)行的,因此數(shù)據(jù)庫(kù)開發(fā)人員可以在不改動(dòng)存儲(chǔ)過程接口的情況下對(duì)數(shù)據(jù)庫(kù)進(jìn)行任何改動(dòng),而這些改動(dòng)不會(huì)對(duì)應(yīng)用程序造成影響。</p><p> (4) 布式工作:應(yīng)用程序和數(shù)據(jù)庫(kù)的編碼工作可以分別獨(dú)立進(jìn)行,而不會(huì)相互壓制。</p><p> 由以上的分析可以看到,在應(yīng)用程序中使用存儲(chǔ)過程是很有必要的。</p><p><b> 存儲(chǔ)過程的調(diào)
29、用方法</b></p><p> 為了突出新方法的優(yōu)點(diǎn),首先介紹一下在.NET中調(diào)用存儲(chǔ)過程的“官方”方法。另外,本文的所有示例程序均工作于SqlServer數(shù)據(jù)庫(kù)上,其它情況類似,以后不再一一說明。本文所有例子均采用C#語(yǔ)言。</p><p> 要在應(yīng)用程序中訪問數(shù)據(jù)庫(kù),一般性的步驟是:首先聲明一個(gè)數(shù)據(jù)庫(kù)連接SqlConnection,然后聲明一個(gè)數(shù)據(jù)庫(kù)命令SqlComm
30、and,用來執(zhí)行SQL語(yǔ)句和存儲(chǔ)過程。有了這兩個(gè)對(duì)象后,就可以根據(jù)自己的需要采用不同的執(zhí)行方式達(dá)到目的。需要補(bǔ)充的是,不要忘記在頁(yè)面上添加如下的引用語(yǔ)句: </p><p> Imports System.Data.SqlClient。</p><p> 就執(zhí)行存儲(chǔ)過程來說,如果執(zhí)行的是第一類存儲(chǔ)過程,那么就要用一個(gè)DataAdapter將結(jié)果填充到一個(gè)DataSet中,然
31、后就可以使用數(shù)據(jù)網(wǎng)格控件將結(jié)果呈現(xiàn)在頁(yè)面上了;如果執(zhí)行的是第二和第三種存儲(chǔ)過程,則不需要此過程,只需要根據(jù)特定的返回判定操作是否成功完成即可。</p><p> 3.ADO.NET的設(shè)計(jì)目標(biāo)</p><p> 隨著應(yīng)用程序開發(fā)的發(fā)展演變,新的應(yīng)用程序已基于 Web 應(yīng)用程序模型越來越松散地耦合。如今,越來越多的應(yīng)用程序使用 XML 來編碼要通過網(wǎng)絡(luò)連接傳遞的數(shù)據(jù)。Web 應(yīng)用程序?qū)?H
32、TTP 用作在層間進(jìn)行通信的結(jié)構(gòu),因此它們必須顯式處理請(qǐng)求之間的狀態(tài)維護(hù)。這一新模型大大不同于連接、緊耦合的編程風(fēng)格,此風(fēng)格曾是客戶端/服務(wù)器時(shí)代的標(biāo)志。在此編程風(fēng)格中,連接會(huì)在程序的整個(gè)生存期中保持打開,而不需要對(duì)狀態(tài)進(jìn)行特殊處理。</p><p> 在設(shè)計(jì)符合當(dāng)今開發(fā)人員需要的工具和技術(shù)時(shí),Microsoft 認(rèn)識(shí)到需要為數(shù)據(jù)訪問提供全新的編程模型,此模型是基于 .NET Framework 生成的。基于.
33、NET Framework這一點(diǎn)將確保數(shù)據(jù)訪問技術(shù)的一致性—組件將共享通用的類型系 統(tǒng)、設(shè)計(jì)模式和命名約定。</p><p> 設(shè)計(jì) ADO.NET 的目的是為了滿足這一新編程模型的以下要求:具有斷開式數(shù)據(jù)結(jié)構(gòu);能夠與 XML 緊密集成;具有能夠組合來自多個(gè)、不同數(shù)據(jù)源的數(shù)據(jù)的通用數(shù)據(jù)表示形式;以及具有為與數(shù)據(jù)庫(kù)交互而優(yōu)化的功能,這些要求都是 .NET Framework 固有的內(nèi)容。</p>&
34、lt;p> 在創(chuàng)建 ADO.NET 時(shí),Microsoft 具有以下設(shè)計(jì)目標(biāo)。</p><p> ADO.NET 的設(shè)計(jì)滿足了當(dāng)今應(yīng)用程序開發(fā)模型的多種要求。同時(shí),該編程模型盡可能地與ADO保持一致,這使當(dāng)今的ADO開發(fā)人員不必從頭開始學(xué)習(xí)全新的數(shù)據(jù)訪問技術(shù)。ADO.NET 是 .NET Framework 的固有部分,因此對(duì)于 ADO 程序員決不是完全陌生的。ADO.NET與ADO共存。雖然大多數(shù)基于
35、.NET 的新應(yīng)用程序?qū)⑹褂肁DO.NET 來編寫,但 .NET 程序員仍然可以通過.NET COM 互操作性服務(wù)來使用 ADO。</p><p> 有關(guān) ADO 和 ADO.NET 之間的差異的論述,請(qǐng)參見 http://msdn.microsoft.com/library/en-us/dndotnet/html/ADONETProg.asp 上的“ADO.NET for the ADO Programmer
36、”。</p><p><b> 支持N層編程模式</b></p><p> ADO.NET為斷開式n層編程環(huán)境提供了一流的支持,許多新的應(yīng)用程序都是為該環(huán)境編寫的。使用斷開式數(shù)據(jù)集這一概念已成為編程模型中的焦點(diǎn)。n 層編程的 ADO.NET 解決方案就是DataSet。</p><p><b> 集成XML支持</b>
37、;</p><p> XML 和數(shù)據(jù)訪問是緊密聯(lián)系在一起的,即 XML 的全部?jī)?nèi)容都是有關(guān)數(shù)據(jù)編碼的,而數(shù)據(jù)訪問越來越多的內(nèi)容都與 XML 有關(guān)。.NET Framework 不僅支持 Web 標(biāo)準(zhǔn),它還是完全基于 Web 標(biāo)準(zhǔn)生成的。</p><p> XML 支持內(nèi)置在 ADO.NET 中非?;镜募?jí)別上。.NET Framework 和ADO.NET 中的 XML 類是同一結(jié)構(gòu)的
38、一部分,它們?cè)谠S多不同的級(jí)別集成。您不必在數(shù)據(jù)訪問服務(wù)集和它們的 XML 相應(yīng)服務(wù)之間進(jìn)行選擇;它們的設(shè)計(jì)本來就具有從其中一個(gè)跨越到另一個(gè)的功能。</p><p> 為什么需要Web Service </p><p> 在通過Internet網(wǎng)購(gòu)買商品后,你可能對(duì)配送方式感到迷惑不解。經(jīng)常的情況是因配送問題找配送公司而消耗你的大量時(shí)間,對(duì)于
39、配送公司而言這也不是一項(xiàng)增值服務(wù)。 </p><p> 為了解決這種問題,配送公司需要在不降低安全級(jí)別的情況下了解更多的遞送信息,然而安全公司設(shè)計(jì)的安全系統(tǒng)卻非常復(fù)雜。那么我們能不能只使用80端口(web服務(wù)器端口)并且只通過web服務(wù)器提供信息呢?所以,我們建立了一個(gè)全新的web應(yīng)用程序以便從核心商業(yè)應(yīng)用程序中獲得數(shù)據(jù)。配送公司將為些東西付money,所有的公司都
40、希望能夠?qū)⒆⒁饬性诤诵纳虡I(yè)應(yīng)用上。 </p><p> 什么是Web Service?</p><p> Web Service是一種構(gòu)建應(yīng)用程序的普通模型,并能在所有支持Internet網(wǎng)通訊的操作系統(tǒng)上實(shí)施。Web Service令基于組件的開發(fā)和web的結(jié)合達(dá)到最佳,基于組件的對(duì)象模型: Distributed Component Object Model (DCO
41、M), Remote Method Invocation (RMI), 和 Internet Inter-Orb Protocol (IIOP) 都已經(jīng)發(fā)布很長(zhǎng)時(shí)間了,不幸的是這些模型都依賴于特殊對(duì)象模型協(xié)議。Web Service利用soap和Xml對(duì)這些模型在通訊方面作了進(jìn)一步的擴(kuò)展以消除特殊對(duì)象模型的障礙。</p><p> Web Service主要利用http和soap協(xié)議使商業(yè)數(shù)據(jù)在web傳輸, s
42、aop通過http調(diào)用商業(yè)對(duì)象執(zhí)行遠(yuǎn)程功能調(diào)用,web用戶能夠使用soap和http通過web調(diào)用的方法來調(diào)用遠(yuǎn)程對(duì)象。</p><p> 那么怎樣使在位置a的用戶明白位置b的Web Service的意思呢?這個(gè)問題可以通過和一個(gè)一致的共同標(biāo)準(zhǔn)來回答。描述性服務(wù)語(yǔ)言(Service Description Language (SDL)),soap訂約語(yǔ)言(SOAP Contract Language (SCL)
43、 )和網(wǎng)絡(luò)訪問規(guī)范語(yǔ)言(Network Accessible Specification Language (NASSL) )都是為這個(gè)目的建立的相似語(yǔ)言,然而IBM和微軟都同意Web Service Description Language (WSDL)作為Web Service 的標(biāo)準(zhǔn)語(yǔ)言。 </p><p> Web Service部件的結(jié)構(gòu)由Web Service Description Languag
44、e.描述,wsdl1.1是一份Xml文檔,描述了Web Service的屬性和接口。新的規(guī)范可以在msdn.microsoft.com/Xml/general/wsdl.asp了解到。</p><p> 最好的學(xué)習(xí)方法是創(chuàng)建一個(gè)Web Service,我們以一個(gè)股票報(bào)價(jià)系統(tǒng)為例,納斯達(dá)克和澳大利亞股票交易系統(tǒng)都是非常有名的例子,他們都提供了一個(gè)接口,用于輸入公司代碼和接受最終成交的股票價(jià)格。我們復(fù)制一個(gè)相同的功
45、能的Web Service。我們的Web Service的輸入?yún)?shù)是股票代碼,Web Service通過調(diào)用中間層商業(yè)邏輯函數(shù)獲得股票價(jià)格,商業(yè)邏輯函數(shù)保持以最小的部分集中在Web Service上。實(shí)現(xiàn)這個(gè)應(yīng)用程序的核心部件將是微軟 .net framework sdk,我的配置是:操作系統(tǒng) windows 2000 server,pIII300,300mb內(nèi)存。創(chuàng)建Web Service的首選集成開發(fā)環(huán)境(IDE)是visual s
46、tudio.net,你可以用任何一種文本編輯器(wordpad,notepad,visual studio6.0)輕易創(chuàng)建一個(gè)Web Service文件。</p><p> Technical Analysis of Network Programming</p><p> 1.Identity Verification of ASP.NET</p><p>
47、 Asp.net have verified the identity of three. are "Windows |Forms| Passport." Among them Forms authentication of the largest and most flexible. </p><p> Forms authentication based on the test wil
48、l provide a good user support, a page posted by users can verify the identity of users of this back in his capacity as the Cookie client. Users visit the Web after this application will be sent to the service together wi
49、th the identity Cookie end. Server can be installed on the authorized list of users under different control of the authority's visit. Then see below about the process. </p><p> Forms authentication basi
50、c tenets : </p><p> Identity verification</p><p> Forms authentication using an identification. Applications must be in the root catalog Web.config corresponding set up to do : </p><
51、;p> <authentication mode="forms"> </p><p> <forms name=".ASPXAUTH " loginUrl="/login.aspx" timeout="30" path= "/"> which <authentication
52、mode= "forms"> said the applications For use Forms authentication. </p><p> 1. <forms> label said the name designated to be used for identification HTTP Cookie. Acquiescence under the na
53、me value is. ASPXAUTH. Verification users adopt this way, users of this information to establish a similar body FormsAuthenticationTicket Verification of these votes, and then into a string encryption sequence. Finally,
54、the string name of the client wrote the names of designated Cookie. Once the Cookie client wrote, This Web users visited this application will be sent to the service toge</p><p> Identity Verification votes
55、, let's look at what the message contained. We look at FormsAuthenticationTicket categories : </p><p> CookiePath : return the path of Cookie. That the path set up for Windows "/". Because Win
56、dows capitalization distinction, which is the URL of the site in order to prevent inconsistencies and capitalization of a protective measure. This in turn use Expiration : Acquiring Cookie Cookie expired Date/Time. </
57、p><p> IsPersistent : If issued lasting Cookie , return true. Otherwise, the identification Cookie would limit the scope of the life cycle in a browser.</p><p> IssueDate : The first issue of Coo
58、kie Acquisition Date/Time. </p><p> Name : access to the user name associated with the identification Cookie. </p><p> UserData : access to applications stored in the Cookie definition string.
59、 </p><p> Version : byte version return for a future use. </p><p> 2. If there is no designated loginUrl in the label<forms> to find any effective identification Cookie, will be posted t
60、o the URL Redirection request. Default values for default.aspx. LoginUrl esignated page is used to verify the identity of users. This page provides general user names and passwords for user input. submitted by the user i
61、n accordance with their own procedures need to verify the legitimacy of users (most of the cases is to the user input information with a few According to library</p><p> Public static void RedirectFormLogin
62、Page(string username, bool createPersistentCookie,string strCookiePath );</p><p> UserName : the user signs to mark the sole user of this marker, Account name not be mapped to the user. createPersistentCoo
63、kie : Cookie whether to issue a permanent marker. Cookie is not durable. Cookie valid Expiration attributes which are present time with sed timeout time, each page request, the identity verification process. over half of
64、 the period will determine whether, and if so to update a cookie is valid; If lasting cookie, Expiration attribute senseless. Then the valid votes identific</p><p> StrCookiePath : marker will be generated
65、by the client Cookie Path. Identity Verification votes to preserve this path is used in the updated identification votes Cookie(which is also generated Cookie the Path), if not strCookiePath parameters, using the attribu
66、tes which in web.config of path's Attribute.</p><p> Here we can see that this method only three parameters, and attributes the identification of seven votes. so is the shortage of four parameters :<
67、/p><p> IssueDate : Cookie issued drawn from the current time.</p><p> Expiration : Next time expired by the time and say that the current <forms> label timeout parameters calculated. This
68、persistent cookie parameters on the non-meaningful. </p><p> UserData :This attribute can be used a number of applications into the user-defined data. I did not use this method attributes, but simply attrib
69、ute this home empty string, please take note of this attribute, We will be behind in the use of this attribute. </p><p> Version : No. version provided by the system automatically.</p><p> Gen
70、eration after generation identification votes RedirectFromLoginPage methods. Call FormsAuthentication.Encrypt will, Encryption will vote for identification string. This will be a string. ASPXAUTH to name a Cookie value.
71、Cookie other attributes of this generation : Domain, the provincial Path To attribute value Expires As createPersistentCookie parameters, If lasting cookie that expired after 50 years as the Expires; If non-persistent co
72、okie, Expires attribute installed. </p><p> Generation identification Cookie, Cookie joined this response. Cookies, awaiting sent to clients. Finally RedirectFromLoginPage method invocation FormsAuthenticat
73、ion.Get RedirectUrl way users access to the original request of the page. Redirection of this page. </p><p> 3. <Forms> labels and the path of the timeout, provide identification to vote is enshrined
74、in the road and acquiescence Cookie time expired. </p><p> Forms authentication is based on the above process, it has completed the confirmation of the identity. Forms are described below based on the ident
75、ification of the mission.</p><p> visit authorization </p><p> Verification of identity is to use this capacity, according to the different operational capacity we can handle. The most common
76、is different for different identities authorized to provide such a certification Forms function. Forms authorization is based on the catalog, catalog can be directed at any authority to set up a visit,for example, These
77、users can access the catalog, users can visit the list of those. Similarly, the authority is set up in which you want to control the web.config file to</p><p> <authorization></p><p> &l
78、t;allow users="comma-separated list of users" </p><p> roles="comma-separated list of roles"</p><p> verbs="comma-separated list of verbs" /></p>
79、<p> <deny users="comma-separated list of users"</p><p> roles="comma-separated list of roles"</p><p> verbs="comma-separated list of verbs" /></p
80、><p> </authorization></p><p> <Allow> label said that it would allow a visit, which attributes :</p><p> 1.Users : a comma separated list of user names, which users had
81、 been granted the right of access to resources. Question mark(?) Allows anonymous users; An asterisk (*) to allow all users. </p><p> 2.Roles : the role of a comma separated list of these roles has been giv
82、en resources to visit the authority.</p><p> 3.Verbs : a comma separated list of HTTP transmission method, HTTP transmission of these methods has been awarded the Access to resources. ASP.NET registration t
83、o the predicate for GET, HEAD, POST and DEBUG.</p><p> <Deny> label said not allowed to visit. With the attributes above. </p><p> In operation, authorized by iterative module <allow
84、> and <deny> markings Until it is the first visit to find a suitable user-specific rules. Then, According to find it is the first visit by the rules <allow>or<deny> rules to permit or refuse to URL.
85、resources visit. Machine.config identification documents default rules <allow users="*"/>, unless otherwise allocation, or acquiescence in the circumstances under which they will allow to visit. </p>
86、;<p> 2.The ASP.NET Using Stored Procedure</p><p> In use. NET process, the database is a very important part of especially in the process of building a system / database operated almost become an e
87、ssential operation. Call stored in the database used to operate many programmers, Most programmers are able to use stored on the use of stored procedure rarely used in SQL. So memory is very useful and very important pro
88、cess. </p><p> 1.Introduction of Stored Procedure </p><p> Simply, storage is control by the process and some SQL language was composed of packaging up the process, its presence in the databas
89、e, client applications can be deployed, can also trigger another process or transfer. Transmission and its parameters can be returned. And the application process function similar names can be stored procedure call, In a
90、ddition, they have the same input parameters and output parameters. </p><p> According to different types of return values, we will be back to record storage process is divided into three categories : the c
91、ollection storage process. Numerical return to the stored procedure (also called scalar stored), and acts stored. By definition, set to return to record the results of the implementation of the storage process is a recor
92、d set, A typical example is retrieved from the database with the records of one or a few conditions; Numerical implementation of the return process is </p><p> 2.The benefits of using stored procedure </
93、p><p> Comparing with the direct use of SQL and stored in the application process by calling the following benefits :</p><p> (1) reduce network traffic. Call a stored procedure and the small num
94、ber of firms directly employ SQL network traffic may not be a great difference. However, if SQL stored procedure contains more than 100 firms. One by one, then the performance of the SQL language than the much higher. &l
95、t;/p><p> (2) the speed of implementation. There are two reasons : First, in the process of building the storage time, the database has already conducted an analysis and optimization. Secondly, the storage pro
96、cess, once implemented, will be retained in memory, a memory of this process, do the same next time, the implementation of stored procedures, can be transferred directly from the memory. </p><p> (3) greate
97、r adaptability : As the visit is stored in the database for the storage process, Database designers can therefore change stored in the database interface in the context of any changes These changes will not impact on the
98、 application process. </p><p> (4) Bush working : applications and the database can work independently, and not mutual repression. </p><p> The above analysis shows that the use of stored proc
99、edures in the application process is very necessary. Calling the process of storage method </p><p> To highlight the advantages of the new method, a briefing on the first. NET stored Calling the "offic
100、ial" approach. In addition, all examples of this process will work in SqlServer database, in other similar situations, no longer setting them out. All examples in this paper use C # language. </p><p>
101、Access to the database application, the general steps : First, a database linking SqlConnection statement. SqlCommand statement then ordered a database used SQL command and storage process. With these two targets, we can
102、 implement according to their needs using different methods to achieve their aims. I must add, do not forget to add the following pages in the application of sentences: Imports System.Data.SqlClient.</p><p>
103、 Storage on the implementation process, if it is the first storage implementation process. So we must use the findings to a DataAdapter to fill a DataSet. Then we can use Data Grid control will result in showing pages;
104、If the second and third storage implementation process, not the process. only under specific needs of the successful completion of the return will determine whether the operation. </p><p> 3.The design aims
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 外文翻譯--socket網(wǎng)絡(luò)編程的設(shè)計(jì)與實(shí)現(xiàn)
- 外文翻譯--socket網(wǎng)絡(luò)編程的設(shè)計(jì)與實(shí)現(xiàn)
- 外文翻譯--socket網(wǎng)絡(luò)編程的設(shè)計(jì)與實(shí)現(xiàn)(英文)
- 外文翻譯--socket網(wǎng)絡(luò)編程的設(shè)計(jì)與實(shí)現(xiàn)(中文)
- 極限編程外文翻譯
- 外文翻譯----編程語(yǔ)言
- java 編程外文翻譯
- 數(shù)控技術(shù)外文翻譯@數(shù)控編程外文文獻(xiàn)翻譯@中英文翻譯
- 外文翻譯--數(shù)控編程 中文
- 編程語(yǔ)言外文翻譯
- 數(shù)控技術(shù)編程設(shè)計(jì)外文文獻(xiàn)翻譯@中英文翻譯@外文翻譯
- 外文翻譯--Socket網(wǎng)絡(luò)編程的設(shè)計(jì)與實(shí)現(xiàn)(有word版).pdf
- 數(shù)據(jù)庫(kù)畢業(yè)設(shè)計(jì)外文翻譯--基于socket的網(wǎng)絡(luò)編程
- 外文翻譯--Socket網(wǎng)絡(luò)編程的設(shè)計(jì)與實(shí)現(xiàn)(有word版).pdf
- 網(wǎng)絡(luò)營(yíng)銷的技術(shù)基礎(chǔ)【外文翻譯】
- 軟件編程設(shè)計(jì)-外文翻譯
- c#編程4.0外文翻譯
- 外文翻譯--網(wǎng)絡(luò)營(yíng)銷的技術(shù)依據(jù)
- 外文翻譯--數(shù)控編程 中文.doc
- 外文翻譯--數(shù)控編程 中文.doc
評(píng)論
0/150
提交評(píng)論