悠闲小风专栏

SharePoint & Workflow 解决方案

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  56 随笔 :: 0 文章 :: 33 评论 :: 46777 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

      在web开发中,开发人员经常要考虑到的一个问题就是如何提升用户体验,用户往往最不愿意看到的是他每点击一次按钮/链接,哪怕只是小部分的页面刷新,页面都会持续一段时间的空白,而AJAX的出现正好让有此需求的开发人员眼前一亮。遗憾的是,在SharePoint 2007中本身是不支持AJAX的,我们需要自己动手去配置支持AJAX的环境,希望在下一个版本中能够集成这一功能,下面就如何让您的sharepoint站点支持AJAX功能做些简要说明,以下所讲的内容都是基于.net framework 2.0,如果您的环境是3.5版本的话,请将以下所有xml代码的版本号更改为Version=3.5.0.0

      在配置前,请确保您的机子已经安装过Microsoft ASP.NET 2.0 AJAX Extensions,安装好后就可以按如下步骤进行配置

      1.打开您的sharepoint站点目录下的web.config文件,通常在路径"系统目录\inetpub\wwwroot\Virtual Directories\端口号\"下可以找到,找到<configSections>节点,在该元素内添加下列XML元素 

复制代码
<sectionGroup name="system.web.extensions"
  type
="System.Web.Configuration.SystemWebExtensionsSectionGroup,
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
  PublicKeyToken=31bf3856ad364e35"
>
    
<sectionGroup name="scripting"
    type
="System.Web.Configuration.ScriptingSectionGroup,
    System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
    PublicKeyToken=31bf3856ad364e35"
>
      
<section name="scriptResourceHandler"
      type
="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
      System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35"
 requirePermission="false" 
      allowDefinition
="MachineToApplication"/>
      
<sectionGroup name="webServices"
      type
="System.Web.Configuration.ScriptingWebServicesSectionGroup,
      System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35"
>
        
<section name="jsonSerialization"
        type
="System.Web.Configuration.ScriptingJsonSerializationSection,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35"
 requirePermission="false" 
        allowDefinition
="Everywhere" />
        
<section name="profileService"
        type
="System.Web.Configuration.ScriptingProfileServiceSection,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35"
 requirePermission="false" 
        allowDefinition
="MachineToApplication" />
        
<section name="authenticationService"
        type
="System.Web.Configuration.ScriptingAuthenticationServiceSection,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35"
 requirePermission="false" 
        allowDefinition
="MachineToApplication" />
    
</sectionGroup>
  
</sectionGroup>
</sectionGroup>
复制代码

      2.找到<system.web>下的<pages>节点,添加下列控件的声明

<controls>
  
<add tagPrefix="asp" namespace="System.Web.UI" 
    assembly
="System.Web.Extensions, Version=1.0.61025.0, 
    Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>
</controls>

      3.在 <assemblies> 节点内添加对程序集的声明

<add assembly="System.Web.Extensions, Version=1.0.61025.0, 
  Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>

      4.找到 <httpHandlers> 节点,往里面添加以下谓词处理程序

复制代码
<add verb="*" path="*.asmx" validate="false" 
  type
="System.Web.Script.Services.ScriptHandlerFactory, 
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"
/>
<add verb="*" path="*_AppService.axd" validate="false" 
  type
="System.Web.Script.Services.ScriptHandlerFactory, 
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"
/>
<add verb="GET,HEAD" path="ScriptResource.axd" 
  type
="System.Web.Handlers.ScriptResourceHandler, 
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"
 validate="false"/>
复制代码

      5.在<httpModules>节点内添加以下脚本模块处理程序

<add name="ScriptModule" 
  type
="System.Web.Handlers.ScriptModule, System.Web.Extensions, 
  Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"
/>

      6.在<SharePoint> 元素中的 <SafeControls> 节点内声明为安全控件

<SafeControl Assembly="System.Web.Extensions, 
  Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"
 Namespace="System.Web.UI" 
  TypeName
="*" Safe="True" />

      7.找到<configuration> 节点,添加以下Web 服务处理程序

复制代码
<system.web.extensions>
    
<scripting>
      
<webServices>
      
<!-- Uncomment this line to enable the authentication 
      service. Include requireSSL="true" if appropriate. 
-->
      
<!--
        <authenticationService enabled="true" 
        requireSSL = "true|false"/>
      
-->
      
<!-- Uncomment these lines to enable the profile service. 
      To allow profile properties to be retrieved and modified in 
      ASP.NET AJAX applications, you need to add each property 
      name to the readAccessProperties and writeAccessProperties 
      attributes. 
-->
      
<!--
        <profileService enabled="true" 
        readAccessProperties="propertyname1,propertyname2" 
        writeAccessProperties="propertyname1,propertyname2" />
      
-->
      
</webServices>
      
<!--
      <scriptResourceHandler enableCompression="true" 
      enableCaching="true" />
      
-->
    
</scripting>
</system.web.extensions>
<system.webServer>
    
<validation validateIntegratedModeConfiguration="false"/>
    
<modules>
      
<add name="ScriptModule" preCondition="integratedMode" 
      type
="System.Web.Handlers.ScriptModule, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>
    
</modules>
    
<handlers>
      
<remove name="WebServiceHandlerFactory-Integrated" />
      
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" 
      preCondition
="integratedMode" 
      type
="System.Web.Script.Services.ScriptHandlerFactory, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>
      
<add name="ScriptHandlerFactoryAppServices" verb="*" 
      path
="*_AppService.axd" preCondition="integratedMode" 
      type
="System.Web.Script.Services.ScriptHandlerFactory, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>
      
<add name="ScriptResource" preCondition="integratedMode" 
      verb
="GET,HEAD" path="ScriptResource.axd" 
      type
="System.Web.Handlers.ScriptResourceHandler, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>
    
</handlers>
</system.webServer>
复制代码

别忘记保存,这样,您的sharepoint站点就能够扩展AJAX的应用了,在下一篇中,将介绍怎样创建支持asp.net ajax的WebPart

posted on   陈典洪  阅读(2756)  评论(1编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示