- 3
- 0
- 约4.5千字
- 约 5页
- 2018-11-23 发布于河南
- 举报
MVC站点和sharepoint集成
目前有一个MVC项目,暂且假设为icrm,我们要将它以虚拟目录的形式部署到sharepoint站点下,以下是具体操作的步骤:
在sharepoint站点中建立虚拟目录
将icrm项目文件拷贝到虚拟目录中,因为虚拟目录和sharepoint站点是同一个程序池,因此我们可以在mvc站点中访问到sharepoint SPContext 对象
在mvc程序中访问sharepoint对象
在view中添加程序集Microsoft.Sharepoint.dll引用
修改sharepoint站点的web.config
添加httpHandlers 节点
httpHandlers
add verb=* path=*.mvc validate=false
type=System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=,
Culture=neutral, PublicKeyToken=31BF3856AD364E35/
/httpHandlers
添加httpModules节点
httpModules
add name=UrlRoutingModule
type=System.Web.Routing.UrlRoutingModule, System.Web.Routing,
Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35 /
/httpModules
添加compilation/assemblies节点
compilation batch=false debug=false
assemblies
add assembly=System.Web.Mvc, Version=, Culture=neutral,
PublicKeyToken=31BF3856AD364E35 /
/assemblies
/compilation
修改mvc站点的web.config
删除scripting节点
sectionGroup name=scripting type=System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35
/sectionGroup
删除 System.Web.UI 节点
controls
add tagPrefix=asp namespace=System.Web.UI assembly=System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35 /
/controls
创建自定义HttpApplication,需要将该程序集注册到sharepoint GAC中
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Diagnostics.CodeAnalysis;
namespace SampleMVC
{
public class CustomHttpApplication :
Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication
{
[SuppressMessage(Microsoft.Security,
CA2109:ReviewVisibleEventHandlers)]
protected virtual void Application_Start(object sender, EventArgs e)
{
//We have to call this empty method otherwise we get a
System.ArgumentException: virtualPath
//If we inlcude System.Web.Routing, then it expects the
following call
RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
//this method needs to be here.
//actual routing is configur
原创力文档

文档评论(0)