启用SharePoint 2010的代码块 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

Sharepoint 在安全设置上,默认禁用了在sharepoint页面中运行C#或vb.net的代码

那什么样才能算是sharepoint页面呢,打开designer ,新建一个aspx页面,在页面中写一些简单的html,

启用SharePoint 2010的代码块

然后用浏览器打开,会正常浏览不会报错。

但如果你在页面中写入C#代码,就会报错

如果想在sharepoint页面中运行C#代码,需要在web.config中添加一个节点

Configuration –> Sharepoint –> SafeMode –> PageParserPaths 在这个里面添加一个

<PageParserPath VirtualPath="/*"
    CompilationMode="Always" AllowServerSideScript="true"  IncludeSubFolders="true"/>

1. VirtualPath 是希望在什么位置启用代码块,路径可写成 “/customer.aspx”  这是网站的路径,

2. 当写了完整的页面名称时,IncludeSubFolders 属性可以不用写,

电脑资料

启用SharePoint 2010的代码块》(https://www.unjs.com)。

3. 除了 Compilation 这个属性外 其他的都很好理解

Compilation中 有3个属性

Always   Auto   Never 这个表示页面中的代码 是不是要被编译。

然后重新启动IIS,就会生效了。

在页面写C#

<script. runat="server">    
protected void Page_Load(object sender, EventArgs e)   
{   
    Response.Write("Hello SharePoint");   
}   
</:script>
最新文章