自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

使用ASP.NET AJAX的Profile Service

開發(fā) 后端
本文介紹使用ASP.NET AJAX的Profile Service,我們不需要手動調(diào)用Sys.Services.ProfileService.set_path方法,只需要在ScriptManager中指定即可。

在ScriptManager中指定Profile Service的Path

在ASP.NET AJAX的客戶端腳本中,如果沒有使用Sys.Services.ProfileService.set_path方法來指定一個提供Profile Service的地址,就會使用默認的地址,它會使ASP.NET AJAX的Profile Service使用程序集中特定的類。一般來說,我們不需要手動調(diào)用Sys.Services.ProfileService.set_path方法,只需要在ScriptManager中指定即可。如下:

  1. <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug"> 
  2. <ProfileService Path="CustomProfileService.asmx" /> 
  3. </asp:ScriptManager> 


實現(xiàn)自己的Web Service類

指定了自己的Web Service類,自然就要實現(xiàn)自己的類了。事實上,我們要實現(xiàn)的就是3個方法。就這個方面來說,ASP.NET AJAX的Profile Service使用的默認的Web Service類Microsoft.Web.Profile.ProfileService是我們絕佳的參考。因此,我們在這里分析一下這些方法,對于我們的自定義工作是非常有幫助的。

可能需要注意的一點是,我們在實現(xiàn)這些方法時,從理論上來講參數(shù)類型不用完全和 Microsoft.Web.Profile.ProfileService中的方法完全相同。ASP.NET AJAX的能夠根據(jù)參數(shù)的類型盡可能地將獲得的JSON字符串轉(zhuǎn)換成需要的類型。不過事實上,似乎 Microsoft.Web.Profile.ProfileService里那些方法的參數(shù)選擇已經(jīng)是非常合理的。另外,由于客戶端Profile Service代碼不太容易修改(事實上客戶端也不是不能擴展,最極端的情況,不就是我們自己實現(xiàn)一個ProfileService嗎?),為了保持返回的JSON字符串能夠被正確處理,這些方法的返回值一般來說可以不變。

GetAllPropertiesForCurrentUser方法

這個方法的作用是獲得當前用戶所有的Profile信息,它沒有輸入的參數(shù),返回的JSON字符串形式如下:

  1. {  
  2. 'ZipCode' : ...,  
  3. 'Address.City' : ...,  
  4. 'Address.State' : ...  

它通過GroupName.ProfileName的形式來表示Profile Group,Group中的每一個Profile需要分別列出,而“...”則表示對應(yīng)Profile值的JSON字符串。

在Microsoft.Web.Profile.ProfileService里,這個方法的代碼如下:

  1. [WebMethod]  
  2. public IDictionary<string, object> GetAllPropertiesForCurrentUser()  
  3. {  
  4. ProfileService.CheckProfileServicesEnabled();  
  5. return ProfileService.GetProfile(HttpContext.Current, null);  

GetPropertiesForCurrentUser方法

這個方法的作用是獲得當前用戶指定的Profile信息,它的輸入JSON字符串形式如下:
['ZipCode', 'Address.City', 'Address.State']

它的返回值的JSON字符串和GetAllPropertiesForCurrentUser相同,就不再贅述了。以上介紹了使用ASP.NET AJAX的Profile Service。

【編輯推薦】

  1. ASP.NET中的WebRequestExecutor
  2. IIS6的ASP.NET ISAPI請求處理過程
  3. ASP.NET中的備份
  4. 淺談ASP.NET ISAPI
  5. ASP.NET的IIS ISAPI extension
責任編輯:佚名 來源: IT168
相關(guān)推薦

2009-07-22 16:05:34

ASP.NET AJA

2009-07-24 13:41:15

ASP.NET AJA

2009-07-22 16:17:39

ASP.NET AJA

2009-07-22 16:11:43

ASP.NET AJA

2009-07-22 16:25:41

ASP.NET AJA

2009-07-30 12:19:32

ASP.NET中使用A

2009-01-16 13:17:16

AjaxASP.NET.NET

2009-01-08 10:20:56

AutoCompletAjaxASP.NET

2009-07-27 17:32:39

Web ServiceASP.NET

2009-07-20 17:39:36

WCF服務(wù)ASP.NET AJA

2009-07-20 10:16:13

配置ASP.NET A

2009-07-29 13:50:26

UpdatePanelASP.NET

2009-07-20 13:14:25

安裝ASP.NET A

2009-07-28 09:02:32

asp.net aja

2009-07-22 15:58:52

ASP.NET AJA

2009-07-31 13:24:43

ASP.NET AJA

2009-07-21 14:37:13

Profile Pro優(yōu)化ASP.NET 2

2009-07-21 17:27:12

UpdateProgrASP.NET AJA

2009-02-20 09:19:56

AJAXASP.NETWeb Service

2009-07-24 13:08:40

AJAX技術(shù)ASP.NET
點贊
收藏

51CTO技術(shù)棧公眾號