All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET2.0数据操作之创建业务逻辑层_[Asp.Net教程]
Asp.net的HttpCookie写入汉字读取时为乱码的解决方法_.net资料_编程技术
javascript特效:将HTML自动转为JS代码_JavaScript技术_编程技术
ASP.NET,2.0中发送电子邮件剖析之一_.net资料_编程技术
应用技巧:用PHP简易实现中文分词_php资料_编程技术
Visual C++ 6.0教程:函数的定义与调用
单击GridView某行获取该行某列内容并显示_[Asp.Net教程]
用Popup对象构建网页右键菜单_JavaScript技术_编程技术
别出心裁搞一搞,日期相加的函数addDate_JavaScript技术_编程技术
用XMLHTTP对象抓取网页源代码,拆分数据写入数据库_[XML教程]
Reading number is top 10 pictures
七步解决性冷淡
农夫山泉变身记
30 beautiful school beauty2
Kim jong il's mistress, national beauty JinYuJi actor3
XuRe xuan cool and refreshing photoes1
为什么别人说你是疯子
The most popular girls welcome eggplant
The money of more than 100 countries and regions17
Absolutely shocked. National geographic 50 animal photographys6
湖南中医院的养生八图
Download software ranking
jBuilder2006
I for your crazy
Tram sex maniac 2 (H) rar bag19
WebService在.NET中的实战应用教学视频 → 第4集
Unix video tutorial5
卡丁车单机版
Boxer's Top ten classic battle10
虚拟机5.5.3版
C语言教程TXT
SP3 for SQL2000
归海一刀 published in(发表于) 2014/1/30 0:51:49 Edit(编辑)
Asp.Net,Ajax,学习笔记16,Profile,Service扩展方式_[Asp.Net教程]

Asp.Net,Ajax,学习笔记16,Profile,Service扩展方式_[Asp.Net教程]

Asp.Net Ajax 学习笔记16 Profile Service扩展方式_[Asp.Net教程]

这次的课程首先说明了Ajax技术滥用的危害。


Ajax是一个很好的技术但是象很多事情一样,过度使用就会有一定的危害。


Round-trip增多导致性能降低。Round-trip就是只提交到服务器和服务器回发的次数增多,这样,增大了服务器的响应次数,导致服务器负担增大。
交互性降低导致用户体验变差。主要的问题在于Ajax是无刷新的在处理页面,有的Ajax页面没有提供数据正在加载的提示,导致用户不清楚现在数据是否正在提交或者加载。
无端使用Ajax技术容易增加安全隐患。因为如果不给WebService加上授权访问,会给网站带来安全方面的问题
Ajax技术是天生的搜索杀手。使用了Ajax的页面可能会导致搜索引擎的搜索程序不能找到。
为了减轻服务器的负担,Ajax应用种应该使用预加载,就是说在页面第一次访问服务器的时候,就将应该回发的数据传送到客户端,用户操作使用Ajax调用的时候不是从服务段取得数据,而是从客户端。


Profile Service的预加载


通过ProfileService的LoadProperties属性,进行Profile的预加载。


客户端调用ProfileSerivce的实质就是Asp.Net Ajax调用包装了Profile的WebService.


那么我们可以通过两种手段来扩展Profile。


1、扩展Asp.Net的Profile


自定义一个Profile类CustomProfile,他继承于System.Web.Profile.ProfileProvider类,CustomProfile类,需要实现以下抽象方法


Initialize
ApplicationName
GetPropertyValues
SetPropertyValues
DeleteProfiles
DeleteInactiveProfiles
GetAllProfiles
GetAllInactiveProfiles
FindProfilesByUserName
FindInactiveProfileByUserName
GetNumberOfInactiveProfiles
然后需要在WebConfig文件里指定ProfileProvider由哪个类来提供。如下例





type="CustomProvider"
connectionStringName="ProfileDatabase"
applicationName="ProfileSample"
description="Sample for ASP.NET profile and Profile Service" />












当然这样继承ProfileProvider的方法,十分的繁琐,我们需要重写很多的基类。


那么Asp.Net Ajax访问Profile的时候,外部包装了一层WebService,我们可以重写这个类。


2、重写Ajax客户端访问Profile的WebService。


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class CustomProfileService : System.Web.Services.WebService
{


[WebMethod]
public IDictionary GetAllPropertiesForCurrentUser()
{
return null;
}


[WebMethod]
public IDictionary GetPropertiesForCurrentUser(string[] properties)
{
return null;
}


[WebMethod]
public int SetPropertiesForCurrentUser(IDictionary values)
{
return 0;
}
}


GetAllPropertiesForCurrentUser方法:从当前用户得到所有的Properties,返回值是一个字典的集合,包含了由客户端传来的键值对应。


GetPropertiesForCurrentUser:从当前用户根据指定的Properties集合名字得到这些Properties字典已和。


SetPropertiesForCurrentUser:为当前的用户设置Properties集合。参数是一个关于这个用户的字典集合。


那么在实现这些方法之后,需要在ScriptManager里指定ProfileService的路径,告诉客户端调用这个Profile Web Service











添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.