Enable code blocks for SharePoint 2010

Source: Internet
Author: User

SharePoint on security settings, the code that runs C # or vb.net on a SharePoint page is disabled by default

So what is a SharePoint page, open Designer, create a new ASPX page, and write some simple HTML on the page.

Then use the browser to open, the normal browsing will not error.

But if you write the C # code on the page, you will get an error.

If you want to run C # code in a SharePoint page, you need to add a node to the web.config

Configuration–> sharepoint–> safemode–> pageparserpaths Add a

<pageparserpath virtualpath= "/*"
    compilationmode= "Always" allowserversidescript= "true"  Includesubfolders= "true"/>

1. VirtualPath is where you want to enable the code block, the path can be written as "/customer.aspx" This is the path to the site,

2. When the full page name is written, the Includesubfolders property can be written without writing.

3. Other than compilation This attribute is very good to understand

There are 3 properties in the compilation

Always Auto Never This indicates whether the code in the page is to be compiled.

Then restart IIS, and it will take effect.

Write C # on the page

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.