冠军

导航

SharePoint 与 ASP.NET 的集成

对于 SharePoint 来说,必须确保每一个入站的请求被路由和处理,对于默认的 ASP.NET 来说,仅仅注册后的扩展名才会被处理,例如:aspx 扩展名,asmx 扩展名等等。首先,SharePoint 配置所有的请求都将会被处理,包括 doc 扩展名,docx 扩展名和 pdf 扩展名。

在 ASP.NET 中,每一个请求都将创建一个处理的上下文 HttpContext,并被 HttpApplication 处理,SharePoint 扩展了 HttpApplication ,这个类是 Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication,这个类定义在程序集 Microsoft.SharePoint.dll 中,在网站的 global.asax  中,如下定义了实际的网站应用程序类:

<@Application Inherits="Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication" >

 

 在 SharePoint 中,请求处理的 HttpApplication 关系图如下所示:

除了 HttpApplication 对象,SharePoint 还自定义了 HttpHandler 和 HttpModule,这两个扩展也使用标准的方式在 web.config 中进行了定义。

<configuration>
  
<system.web>
    
<httpHandlers>
      
<remove verb="GET,HEAD,POST" path="*" />
      
<add verb="GET,HEAD,POST" path="*"
           type
="Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler, ..." />
    
</httpHandlers>
    
<httpModules>
      
<clear />
      
<add name="SPRequest"
           type
="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, ..." />
      
<!-- other standard ASP.NET httpModules added back in -->
    
</httpModules>
  
</system.web>
</configuration>

 

SharePoint 还定义了名为 SPRequestModule  的 Module 来初始化 SharePoint 环境。

SharePoint 使用自定义的配置节扩展标准的 web.config 配置文件。

<configuration>
  
<configSections>
    
<sectionGroup name="SharePoint">
      
<section name="SafeControls" type="..." />
      
<section name="RuntimeFilter" type="..." />
      
<section name="WebPartLimits" type="..." />
      
<section name="WebPartCache" type="..." />
      
<section name="WebPartWorkItem" type="..." />
      
<section name="WebPartControls" type="..." />
      
<section name="SafeMode" type="..." />
      
<section name="MergedActions" type="..." />
      
<section name="PeoplePickerWildcards" type="..." />
    
</sectionGroup>
  
</configSections>

  
<SharePoint>
    
<SafeMode />
    
<WebPartLimits />
    
<WebPartCache />
    
<WebPartControls />
    
<SafeControls />
    
<PeoplePickerWildcards />
    
<MergedActions />
    
<BlobCache />
    
<RuntimeFilter />
  
</SharePoint>
</configuration>

 

对于网站内容来说,SharePoint 通过自定义的 SPVirtualPathProvider 来提供,这一点与经典的 ASP.NET 网站不同,在经典的 ASP.NET 网站中,通过基于文件目录的提供器来取得网站内容,而 SharePoint 通过 SQLServer 来处理。当你创建一个页面,并保存到 SharePoint 的时候,这个页面被实际保存到 SharePoint 的内容数据库中,当访问这个页面的时候,页面从内容数据库中读取出来。

 

对于 SharePoint 网站来说,还创建了许多虚拟目录。像 _layouts、controltemplates 等等。

这些虚拟目录映射到服务器的特定目录下。_layouts  目录中包含了特定类型的页面。

c:\program files\common files\microsoft shared\web server extensions

 

 一些 SharePoint 中的页面支持定制,这种页面称为站点页 Site Pages,支持定义提供了巨大的灵活性,但是也有缺点,为了灵活而又不影响扩展性,SharePoint 必须采取一些措施。

在 SharePoint 中还提供了一种称为 Application Page,这种页面不支持定制,因此,可以规避一些性能和安全方面的问题。

标准的站点设置页面就是 Application Page 的典型例子,可以在任何站点访问它,页面在系统的如下目录中:

c:\program files\common files\microsoft shared\web server extensions\12\TEMPLATE\LAYOUTS

 

下图是 WSS3.0 中的 layouts 中的内容。注意,上文中的 _layouts 将会映射到这个文件夹。

posted on 2010-12-18 23:42  冠军  阅读(2778)  评论(3编辑  收藏  举报