Use Profile Service of ASP. NET AJAX

Source: Internet
Author: User

Specify the Path of the Profile Service in ScriptManager.

In ASP. net ajax client script, if Sys. services. profileService. if the set_path method is used to specify an address that provides the Profile Service, the default address is used.. net ajax Profile Service uses a specific class in the Assembly. Generally, you do not need to manually call the Sys. Services. ProfileService. set_path method. You only need to specify it in ScriptManager. As follows:

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


Implement your own Web Service class

If you specify your Web Service class, you must implement your class. In fact, we need to implement three methods. In this regard, the Profile Service of ASP. net ajax uses the default Web Service Microsoft. Web. Profile. ProfileService, which is an excellent reference. Therefore, analyzing these methods here is very helpful for our custom work.

It may be worth noting that when we implement these methods, theoretically speaking, the parameter type does not need to be exactly the same as that in Microsoft. Web. Profile. ProfileService. ASP. net ajax can convert the obtained JSON string to the desired type based on the parameter type as much as possible. But in fact, it seems that the parameter selection for those methods in Microsoft. Web. Profile. ProfileService is already very reasonable. In addition, the client Profile Service code is not easy to modify. In fact, the client cannot be expanded. In the most extreme case, isn't it because we implement a ProfileService ourselves ?), In order to ensure that the returned JSON string can be correctly processed, the return values of these methods can remain unchanged.

GetAllPropertiesForCurrentUser Method

This method is used to obtain all Profile information of the current user. It does not have any input parameters. The returned JSON string format is as follows:

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

It uses GroupName. ProfileName to represent the Profile Group. Each Profile in the Group needs to be listed separately, and "..." indicates the JSON string corresponding to the Profile value.

In Microsoft. Web. Profile. ProfileService, the code for this method is as follows:

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

GetPropertiesForCurrentUser Method

This method is used to obtain the Profile information specified by the current user. Its input JSON string format is as follows:
['Zipcode', 'address. city', 'address. state']

It returns the same JSON string as GetAllPropertiesForCurrentUser, so we will not repeat it here. The above describes the use of ASP. net ajax Profile Service.

  1. WebRequestExecutor in ASP. NET
  2. IIS6 ASP. net isapi request processing process
  3. Backup in ASP. NET
  4. Introduction to ASP. NET ISAPI
  5. Iis isapi extension of ASP. NET

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.